arckinteractive / elgg_solr
基本的solr集成,用于替代elgg搜索
Requires
- php: >=5.4
- composer/installers: ^1.2
- ezyang/htmlpurifier: 4.7.0
- jumbojett/vroom: dev-master
- solarium/solarium: 3.6.*
README
通过使用专用Solr搜索索引来加速站点搜索
- 搜索实体
- 搜索标签(精确匹配)
- 搜索文件内容
此插件遵循默认Elgg搜索插件的结构,可以使用相同的搜索插件钩子进行扩展。
依赖项
- 此插件依赖于默认的elgg搜索插件(与Elgg捆绑提供)
- 此插件依赖于vroom插件 - https://github.com/jumbojett/vroom
安装
-
下载插件并将其上传到
/mod/elgg_solr
,或使用composer安装composer require arckinteractive/elgg_solr:~2.0
-
在“管理 > 插件”中,将
elgg_solr
插件重新排序,使其位于search
插件下方,并启用它 -
创建一个新的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
- 如果使用Solr 5,将
- 确保
-
更新
elgg_solr
插件设置,使其指向新的Solr实例 -
从插件设置页面触发重新索引
-
确保已配置并激活每日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
- guidtype
- 实体类型subtype
- 实体子类型owner_guid
- 所有者的guidcontainer_guid
- 容器的guidaccess_id
- 访问级别title
- 标题name
- 名称description
- 描述time_created
- 创建时间戳time_updated_i
- 最后更新时间戳enabled
- 实体是否启用tag_<tag_name>_ss
- 已注册的标签元数据名称的标签has_pic_b
- 标志表示实体已上传图标responses_thread_i
- 评论/回复线程根的guidresponses_is
- 评论/回复的guidresponses_count_i
- 评论/回复的总数likes_count_i
- 喜欢的总数
用户
除了实体字段外
username
- 用户名profile_<field_name>_s
- 单个值的配置文件字段profile_<field_name>_ss
- 具有多个值(标签)的配置文件字段groups_is
- 用户是成员的组的guidgroups_count_i
- 用户是成员的组总数friends_is
- 用户的朋友的guidfriends_count_i
- 好友总数last_login_i
- 最后登录时间戳last_action_i
- 最后活动时间戳has_pic_b
- 表示用户是否有头像的标志
组
除了实体字段外
group_<field_name>_s
- 具有单个值的个人资料字段group_<field_name>_ss
- 具有多个值的个人资料字段(标签)members_is
- 组成员的 guidsmembers_count_i
- 组成员总数
文件
要索引文件内容,请在插件设置中启用提取(extract_handler
)。
除了实体字段外
attr_content
- 提取的内容simpletype_s
- 简单类型(例如image
,document
等)mimetype_s
- 识别的 MIME 类型(例如application/json
)originalfilename_s
- 上传文件的原始名称filesize_i
- 文件大小(字节)