Liferay DXP Elastic Search Integration Tutorial
This tutorial is to integrate Liferay 7 with elastic search tool. Liferay 7 out of the box comes with elastic search in embedded mode,but this is not recommended for production release. Liferay 7 applications are required to configure with elastic search server mode. Liferay 7 compatible with elastic search version 2.2 only.
What is Elastic Search?
Elasticsearch built on top of Lucene and distributed RESTful search engine built for the cloud. It has the following features:
- HTTP RESTful API
- Document oriented
- Real Time Search
- Each index is fully sharded with a configurable number of shards.
- Distributed and Highly Available Search Engine.
- Single document level operations are atomic, consistent, isolated and durable.
Installations:
- Elastic Search v2.2
- Liferay 7
Install Elastic Search Server:
- Download Elastic search from here
- Extract to local file system like shown below
- Edit cluster.name in elasticsearch-2.2.0\config\elasticsearch.yml file and set to LiferayElasticsearchCluster which is default name liferay is using.
-
cluster.name: LiferayElasticsearchCluster node.name: Javasavvy
-
- Now start the elastic search server from bin and Elasticsearch uses port 9200 for REST API, so access localhost:9200 in the browser and you will get below response.This port is configurable if necessary.
Liferay Elastic Search Integration:
In this step, we will configure elastic search in Liferay and this can be done in the following ways:
- Control panel
- In the control panel, navigate to control panel -> configuration -> System Settings -> Foundation
- You can find ElasticSearch and click on Edit
- Now change Operation mode from Embed to Remote and save the configuration. You can also update transport host and port from localhost to elastic search server IP address. so keep localhost only as we are configuring elastic search in same machine.
- via Configuration file:
- create elastic-search config file: “com.liferay.portal.search.elasticsearch.configuration.ElasticsearchConfiguration.cfg”
- copy the below properties and copy to bundles\osgi\configs folder
- Restart the server:
-
operationMode=REMOTE clientTransportIgnoreClusterName=false indexNamePrefix=liferay- httpCORSConfigurations= additionalConfigurations= httpCORSAllowOrigin=/https?://localhost(:[0-9]+)?/ networkBindHost= transportTcpPort= bootstrapMlockAll=false networkPublishHost= clientTransportSniff=true additionalIndexConfigurations= retryOnConflict=5 httpCORSEnabled=true clientTransportNodesSamplerInterval=5s additionalTypeMappings= logExceptionsOnly=true httpEnabled=true networkHost= transportAddresses=localhost:9300 discoveryZenPingUnicastHostsPort=9300-9400 clusterName=LiferayElasticsearchCluster
-
Re index:
Login to tomcat server again and go to control panel => Server Administration and click on re-index
after re-index access the below in URL: http://localhost:9200/_search?pretty=true or http://localhost:9200/liferay-20116/_search?pretty=true
Result:
Hope this helps!!!
2 thoughts on “Liferay DXP Elastic Search Integration Tutorial”
Comments are closed.
Is this configuration is sufficient in prod environment?
Can you please suggest if any other settings are required?
Hi,
I have configured remote mode properly from the Different IP & JVM in the box.
But I am getting “ReceiveTimeoutTransportException” in the console.
Any help?