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:

  1. Download Elastic search from here
  2. Extract to local file system like shown below Liferay ElasticSearch
  3. Edit cluster.name in  elasticsearch-2.2.0\config\elasticsearch.yml file and set to LiferayElasticsearchCluster which is default name liferay is using.
    1.  cluster.name: LiferayElasticsearchCluster
       node.name: Javasavvy
  4. 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.

    elastic search 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 EditLiferay Elastic search control panel configuration
    • 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.oper
  • 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:
      1. 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:

elastic response

 

Hope this helps!!!

 

2 Comments

  1. Subba

    Is this configuration is sufficient in prod environment?

    Can you please suggest if any other settings are required?

    Reply
  2. Subba

    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?

    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *