Speed up site search by using a dedicated Solr search index
- Search Entities
- Search tags (exact match)
- Search File contents
This plugin follows the structure of the default Elgg search plugin, can be extended using the same search plugin hooks.
- This plugin depends on the default elgg search plugin (bundled with Elgg)
- This plugin depends on the vroom plugin - https://github.com/jumbojett/vroom
-
Download the plugin and upload it to
/mod/elgg_solr, or install with composercomposer require arckinteractive/elgg_solr:~2.0 -
In Admin > Plugins, reorder the
elgg_solrplugin to be positioned undersearchplugin, and enable it -
Create a new Solr instance and configure it:
- Make sure that
/<instance>/conf/solrconfig.xmlis set to use classic index schema:<schemaFactory class="ClassicIndexSchemaFactory"></schemaFactory> - Copy contents of
install/schema.xml(orinstall/schema.solr5.xmlfor Solr 5+) included in the root of the plugin to/<instance>/conf/schema.xml- Copy contents of
install/solrconfig.solr5.xmlto `//conf/solrconfig.xml if using solr 5
- Copy contents of
- Make sure that
-
Update
elgg_solrplugin settings to point to the new Solr instance -
Trigger a reindex from the plugin setting page
-
Ensure that daily cron is configured and active
search, <search_type>
search, <entity_type>
search, <entity_type>:<entity_subtype>
These hooks can be used to modify search criteria
elgg_solr:index, <entity_type>
elgg_solr:index, <entity_type>:<entity_subtype>
elgg_solr:index, annotation
These hooks can be used to customize indexed fields
elgg_solr:can_index, annotation
Allows to add annotations to index by name
elgg_solr:access, entities
Allows plugins to add additional access queries.
Indexed values can be customized using 'elgg_solr:index',<entity_type>' hook:
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;
});To add an annotation to the index, add annotation name to the return of the '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- entity typesubtype- entity subtypeowner_guid- guid of the ownercontainer_guid- guid of the containeraccess_id- access leveltitle- titlename- namedescription- descriptiontime_created- timestamp of the creationtime_updated_i- timestamp of the last updateenabled- is entity enabledtag_<tag_name>_ss- tags for registered tag metadata nameshas_pic_b- flag indicating that entity has an uploaded iconresponses_thread_i- guid of the comment/reply thread rootresponses_is- guids of comments/repliesresponses_count_i- total count of comments/replieslikes_count_i- total count of likes
In addition to Entity fields:
username- usernameprofile_<field_name>_s- profile fields with a single valueprofile_<field_name>_ss- profile fields with multiple values (tags)groups_is- guids of groups a user is member ofgroups_count_i- total number of groups a user is a member offriends_is- guids of user's friendsfriends_count_i- total number of friendslast_login_i- timestamp of the last loginlast_action_i- timestamp of the last activityhas_pic_b- flag indicating that user has an avatar
In addition to Entity fields:
group_<field_name>_s- profile fields with a single valuegroup_<field_name>_ss- profile fields with multiple values (tags)members_is- guids of group membersmembers_count_i- total number of group members
To index file contents, enable extraction (extract_handler) in plugin settings.
In addition to Entity fields:
attr_content- extracted contentssimpletype_s- simple type (e.g.image,documentetc)mimetype_s- detected mime type (e.g.application/json)originalfilename_s- original name of the uploaded filefilesize_i- file size in bytes