Skip to content
This repository has been archived by the owner on Aug 15, 2023. It is now read-only.

Setting up Alfresco with Elasticsearch

astocks7 edited this page Apr 6, 2020 · 5 revisions

Prerequisites

Know how to build OpenContent on top of Alfresco.

Starting Elasticsearch and Kibana

  • Download Elasticsearch and extract files.

  • Download Kibana and extract files (make sure to download same version as elasticsearch).

  • Navigate to <elasticsearch_home>/bin and run elasticsearch.bat from a command prompt. Once deployed you should be able to see some verification JSON at localhost:9200

  • Navigate to <kibana_home>/bin and run kibana.bat from a command prompt. Once deployed you should be able to see Kibana at localhost:5601. Kibana is a dashboard/visualization tool that allows you to view/monitor your Elasticsearch indices.

Building OpenContent

  • Now that you have elasticsearch and kibana up and running, all you need to do is build OpenContent using the hpi-demo-alf project with some slight adjustments.

  • Navigate to the build.gradle for hpi-demo-alf and uncomment the :2.elasticsearch and :3.elasticsearchAlfresco modules.

  • Navigate to the project-bean-config.xml for hpi-demo-alf and uncomment the imports for elasticsearch-bean-config.xml and alfresco-elasticsearch-bean-config.xml.

  • In the 2.elasticsearch module, you will find elasticsearch-defaults.properties. These are the default configurations for an elasticsearch setup. You may have to override some of these in your override-placeholders.properties

    • Note: OCMS sets document icons in the search results based on the what the mimetype is on the object. Use elasticsearch.mimeTypeAttrName to set a property as the mimetype. For example, if documents in your index have a tsg:nativeMimetype property that signifies the mimetype, then set this as the value for elasticsearch.mimeTypeAttrName

One more thing to take note of is the objectTypeFilter bean in alfresco-elasticsearch-bean-config.xml in the 3.elasticsearchAlfresco module. Due to the invert property being set, this is a blacklist for objectTypes that we don't want to be indexed. This is useful because other things (user preferences for example, which we don't want to be indexed) trigger our onCreate and onUpdate events that handle our elasticsearch indexing. Adding objectTypes to this list will filter them out. For reference, our event listeners can be found in ExternalIndexEvent.java

After making these changes you should be good to go. Build OpenContent with the hpi-demo-alf project.

Deploying OCMS

  • Make sure enableIndexing in the config-project.js that exists in the hpi-demo-alf project is set to true. This ensures that the configuration of external indexing will be available when you build OCMS.

Configuring object type indexing

Once you've got OCMS up and running, in order to get your documents indexing with elasticsearch you will have to do some simple configuration in the OCMS Admin.

  • Navigate to the admin page, then click on object types. Navigate to the object type(s) that you would like to be indexed with elasticsearch. Open that object type via the dropdown arrow and select the checkbox next to Index. Scroll to the bottom and save the config. Now your object type is all set up for external indexing!

Querying for multiple object types

In the less common scenario where you will be querying on multiple object types, the following behavior can be expected when set up for external indexing.

  • If all object types in the query are set up for external indexing, then the query will search on those external indices.
  • If all object types in the query are NOT set up for external indexing, then the query will fallback to searching via Alfresco.
  • If some object types in the query are set up for indexing, and others are not, an error will occur.
Clone this wiki locally