定制 coldtrick/opensearch 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

coldtrick/opensearch

Composer 安装命令:

composer require coldtrick/opensearch

包简介

An OpenSearch implementation for Elgg

README 文档

README

Elgg 6.2 Elgg 7.0 OpenSearch 2.5 Lint Checks Latest Stable Version License

An OpenSearch implementation for Elgg

Requirements

A working OpenSearch server is required. Also the minute cron has to be working on your Elgg installation. The minute cron is used to update the index with all the required changes (create/update/delete).

The current supported version of OpenSearch is: 2.5.x

Configuration

Settings

The plugin settings allow you to configure the following:

  • Hosts: 1 or more hosts need to be configured (full URL + optional port number). You can provide more hosts comma seperated.
  • Index: Name of the index used for indexing Elgg data and search queries
  • Search alias (optional): Name of the alias to use in search queries, this allows for easy searching across multiple indices

Index Management

The index management page (found under Administer -> OpenSearch -> Indices in the admin sidebar) allows you to perform various actions on all the indexes available on the OpenSearch server. The following actions are supported:

  • Create: This action can only be performed if the index configured in the plugin settings page is not yet available. It will create the default index configuration to be used for search.
  • Alias: Add/remove the configured alias to the index (this allows searching across multiple indices)
  • Delete: This will remove the index from the server (this action can not be undone)

Administration

Log files

Based on the log level of your Elgg site, there will also be logging of the OpenSearch PHP client library. Logging will appear in the same location as all other Elgg logs.

Statistics

You can find various statistics on the Administer -> OpenSearch -> Statistics page. Elgg statistics report on the amount of entities found in the Elgg database that should be in the index. It also reports on the amount of entities that need to be added/updated/deleted in the index and that are currently waiting on the minute cron to process them.

Also some statistics from the OpenSearch Cluster are shown like the status and the version information.

You can also find statistics for all available indexes on this page.

CLI commands

CLI commands are available to be used with the default elgg-cli command

opensearch:rebuild

This command will rebuild the current OpenSearch index with new configuration and/or mappings. This only works when there is an active index. Only use this command when a change was made to the index configuration and/or mappings.

opensearch:sync

This command will synchronize all pending entities to the OpenSearch index. This is especially usefull during the reindexing process of the database because a lot of entities need to be indexed. Using the normal cron task in this case could take a long time.

Recommendations

Use the Search Advanced plugin to add extra features to search. If both are enabled this plugin provides a menu to sort/order the results.

Developers

Plugin events

'boostable_types', 'opensearch'

Return an array of type.subtype to be used for configuring boosting in OpenSearch.

In the format:

[
	'type.subtype',
]

Defaults to the registered searchable type/subtypes for OpenSearch.

'config:index', 'opensearch'

Return an array with the index configuration to be used by OpenSearch.

'config:mapping', 'opensearch'

Return an array with the mapping configuration to be used by OpenSearch.

'export:counters', 'opensearch'

Return an array of counters to be exported to OpenSearch.

In the format:

[
	'counter_name' => counter_value
]

Params contain:

  • entity: the ElggEntity being exported

'export:metadata_names', 'opensearch'

Return an array of metadata names to be exported to OpenSearch.

Params contain:

  • entity: the ElggEntity being exported

'export:relationship_names', 'opensearch'

Return an array of relationship names to be exported to OpenSearch.

Params contain:

  • entity: the ElggEntity being exported

'index_entity_type_subtypes', 'opensearch'

Return an array of type/subtypes allowed to be indexed by OpenSearch.

In the format:

[
	'type' => ['subtype1', 'subtype2'],
]

Defaults to all registered searchable type/subtypes in Elgg.

'index:entity:prevent', 'opensearch'

Return true if the provided entity shouldn't be added to the OpenSearch index

Params contain:

  • entity: the ElggEntity about to be indexed

Default: false

'index:entity:type', 'opensearch'

Return a string under which type/subtype the entity should be indexed. This is used for type filtering during the search (eg. all blogs)

Params contain:

  • entity: the ElggEntity about to be indexed
  • default: the default type/subtype for this entity

Default: {entity_type}.{entity_subtype} (eg. object.blog)

'params', 'opensearch'

Return an array of parameters to be using in initializing the \ColdTrick\OpenSearch\Client OpenSearch client.

'search', 'type_subtype_pairs'

Return an array of type/subtypes allowed to be searched by OpenSearch.

In the format:

[
	'type' => ['subtype1', 'subtype2'],
]

Defaults to all registered searchable type/subtypes in Elgg.

'search_params', 'opensearch'

Return an \ColdTrick\OpenSearch\Di\SearchService to be used for the search. This allows you to alter the search parameters in opensearch.

Params contain:

  • search_params: an array of the search parameters as provided by Elgg search

'to:entity:before', 'opensearch'

Change the OpenSearch hit data before it's converted to an ElggEntity

Params contain:

  • hit: the result from OpenSearch
  • search_params: an array of the search parameters as provided by Elgg search

'to:entity', 'opensearch'

Return an ElggEntity based on the search result data from OpenSearch.

Params contain:

  • hit: the result from OpenSearch
  • search_params: an array of the search parameters as provided by Elgg search

Parameters passed to elgg_search

field_boosting

In the parameters passed to elgg_search you can add a configuration to control field boosting in OpenSearch. Add the key field_boosting to the array which holds an array with field-name and the boosting for that field.

Example:

[
	'field_boosting' => [
		'title' => 2, // title is worth double
		'description' => 0.5 // description is worth half
	],
]

coldtrick/opensearch 适用场景与选型建议

coldtrick/opensearch 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.1k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 02 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「plugin」 「search」 「lucene」 「opensearch」 「elgg」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 coldtrick/opensearch 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 coldtrick/opensearch 我们能提供哪些服务?
定制开发 / 二次开发

基于 coldtrick/opensearch 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1.1k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 11
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-only
  • 更新时间: 2022-02-17