ElasticSearch cluster

ElasticSearch cluster

OpenMRS core 2.8.x introduces the ElasticSearch backend support as an in-place replacement for the Lucene in-memory index. Lucene remains the default search index that is suitable for single machine deployments. It can be replaced with ElasticSearch with a simple configuration change.

ElasticSearch is a highly scalable solution for full text search capabilities. The ElasticSearch cluster can be deployed on-premise or it can be used as a SAAS from many cloud providers.

OpenMRS uses Hibernate Search for full text search (e.g. concept and patient searches), which can be setup with the Lucene in-memory index (by default) or connected to a running ElasticSearch cluster.

If you plan to run OpenMRS in a cluster, it is recommended to configure it to run with an ElasticSearch cluster instead of Lucene. It is going to be possible to run multiple replicas of OpenMRS with ElasticSearch backend only.

It is also recommended to use an ElasticSearch cluster, if you see increased load on your OpenMRS instance. The use of ElasticSearch will distribute some of the load to dedicated search infrastructure.

In order to configure OpenMRS to use ElasticSearch you need to provide the following configuration properties (via installation script / openmrs-runtime.properties / Java or OS env variables):

hibernate.search.backend.type=elasticsearch hibernate.search.backend.analysis.configurer=elasticsearchConfig hibernate.search.backend.uris=http://es:9200

If you change the backend in an existing system, you need to restart the server and rebuild search indexes by going to Legacy UI -> Administration -> Search Index. Alternatively you can rebuild the search index using the searchindexupdate REST endpoint.

All supported configuration properties can be found in the Hibernate Search documentation.

An example setup with docker-compose is available here with run instructions in README.md. The docker setup includes two convenient variables that change all required properties:

OMRS_SEARCH=elasticsearch OMRS_SEARCH_ES_URIS=http://es:9200