arckinteractive/elgg_solr

基本的solr集成,用于替代elgg搜索

安装: 444

依赖项: 0

建议者: 0

安全: 0

星标: 7

关注者: 9

分支: 8

开放问题: 1

类型: elgg插件

2.2.8 2018-04-05 18:48 UTC

README

通过使用专用Solr搜索索引来加速站点搜索

  • 搜索实体
  • 搜索标签(精确匹配)
  • 搜索文件内容

此插件遵循默认Elgg搜索插件的结构,可以使用相同的搜索插件钩子进行扩展。

依赖项

安装

  1. 下载插件并将其上传到 /mod/elgg_solr,或使用composer安装 composer require arckinteractive/elgg_solr:~2.0

  2. 在“管理 > 插件”中,将 elgg_solr 插件重新排序,使其位于 search 插件下方,并启用它

  3. 创建一个新的Solr实例并配置它

    • 确保 /<instance>/conf/solrconfig.xml 设置为使用经典索引模式: <schemaFactory class="ClassicIndexSchemaFactory"></schemaFactory>
    • 将插件根目录中包含的 install/schema.xml 的内容(或Solr 5+的 install/schema.solr5.xml)复制到 /<instance>/conf/schema.xml
      • 如果使用Solr 5,将 install/solrconfig.solr5.xml 的内容复制到 //conf/solrconfig.xml
  4. 更新 elgg_solr 插件设置,使其指向新的Solr实例

  5. 从插件设置页面触发重新索引

  6. 确保已配置并激活每日cron

插件钩子

search, <search_type>

search, <entity_type>

search, <entity_type>:<entity_subtype>

可以使用这些钩子修改搜索条件

elgg_solr:index, <entity_type>

elgg_solr:index, <entity_type>:<entity_subtype>

elgg_solr:index, annotation

可以使用这些钩子自定义索引字段

elgg_solr:can_index, annotation

允许通过名称添加注释到索引

elgg_solr:access, entities

允许插件添加额外的访问查询。

索引

调整索引值

可以使用 'elgg_solr:index',<entity_type>' 钩子自定义索引值

elgg_register_plugin_hook_handler('elgg_solr:index', 'object', function($hook, $type, $return, $params) {

	$entity = elgg_extract('entity', $params);
	if (!$entity instanceof Event) {
		return;
	}

	$return->custom_field_s = $entity->custom_field;
	$return->start_time_i = $entity->start_time;
	return $return;
});

将注释添加到索引中

要将注释添加到索引中,请将注释名称添加到 'elgg_solr:can_index','annotation' 的返回值中

elgg_register_plugin_hook_handler('elgg_solr:can_index', 'annotation', function($hook, $type, $return) {
	$return[] = 'revision';
	return $return;
});

索引值

实体

  • id - guid
  • type - 实体类型
  • subtype - 实体子类型
  • owner_guid - 所有者的guid
  • container_guid - 容器的guid
  • access_id - 访问级别
  • title - 标题
  • name - 名称
  • description - 描述
  • time_created - 创建时间戳
  • time_updated_i - 最后更新时间戳
  • enabled - 实体是否启用
  • tag_<tag_name>_ss - 已注册的标签元数据名称的标签
  • has_pic_b - 标志表示实体已上传图标
  • responses_thread_i - 评论/回复线程根的guid
  • responses_is - 评论/回复的guid
  • responses_count_i - 评论/回复的总数
  • likes_count_i - 喜欢的总数

用户

除了实体字段外

  • username - 用户名
  • profile_<field_name>_s - 单个值的配置文件字段
  • profile_<field_name>_ss - 具有多个值(标签)的配置文件字段
  • groups_is - 用户是成员的组的guid
  • groups_count_i - 用户是成员的组总数
  • friends_is - 用户的朋友的guid
  • friends_count_i - 好友总数
  • last_login_i - 最后登录时间戳
  • last_action_i - 最后活动时间戳
  • has_pic_b - 表示用户是否有头像的标志

除了实体字段外

  • group_<field_name>_s - 具有单个值的个人资料字段
  • group_<field_name>_ss - 具有多个值的个人资料字段(标签)
  • members_is - 组成员的 guids
  • members_count_i - 组成员总数

文件

要索引文件内容,请在插件设置中启用提取(extract_handler)。

除了实体字段外

  • attr_content - 提取的内容
  • simpletype_s - 简单类型(例如 imagedocument 等)
  • mimetype_s - 识别的 MIME 类型(例如 application/json
  • originalfilename_s - 上传文件的原始名称
  • filesize_i - 文件大小(字节)