Exercise: Install Elasticsearch

Availability: Liferay DXP 7.3, Liferay Portal CE 7.3 GA4+

Here you can walk through an example setup on your local machine to see how the Rest Client connection between Elasticsearch and Liferay DXP 7.3 is configured. The example uses two Docker containers: one Elasticsearch container and one Liferay DXP container. For more conceptual and production-like information see Installing Elasticsearch.

Read Securing Elasticsearch to enable authentication and encryption on the Elasticsearch connection.

Create Local Folders for Bind Mounting to the Docker Containers

Create a local folder structure that can be bind mounted to the Elasticsearch and DXP containers’ system folders for providing plugins and configuration files:

mkdir -p test-es-install/dxp/files/osgi/configs && mkdir -p test-es-install/elasticsearch && cd test-es-install


The cd test-es-install command at the end puts you in the test-es-install folder. Make sure you run the remaining commands for both Elasticsearch and Liferay DXP from this folder.

Install Elasticsearch

  1. Configure and start an Elasticsearch 7.9.0 container named elasticsearch790:

    docker run -it --name elasticsearch790 -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e "" -v $(pwd)/elasticsearch:/usr/share/elasticsearch/data
  2. Install the required Elasticsearch plugins. Use docker exec -it to access an interactive bash shell:

    docker exec -it elasticsearch790 bash -c '/usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-icu && /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-kuromoji && /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-smartcn && /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-stempel'
  3. Restart the Elasticsearch container to register the plugins. CTRL+C stops the container, then start it again by running

    docker start -i elasticsearch790
  4. Get the IPv4 address of the running Elasticsearch container:

    docker network inspect bridge

    In this example it’s If your system provides a different IP address, you must use it in the docker run --add-host elasticsearch790:[IP]... command when running Liferay DXP.

    "Containers": {
                "2d4614fdcce2159322fa7922bfc5f866b79bd7f609a65cc888f9a260f80731f4": {
                    "Name": "elasticsearch790",
                    "EndpointID": "e89c3d0a87cc528753470eb359cee3b85fea9f9a5df3b249d54d203741a650a8",
                    "MacAddress": "02:42:ac:11:00:02",
                    "IPv4Address": "",
                    "IPv6Address": ""

Install Liferay DXP

Specify the properties Liferay DXP needs to connect with Elasticsearch, then run the DXP container.

  1. First populate the Elasticsearch 7 configuration file by running

    cat <<EOT >> dxp/files/osgi/configs/
  2. Once the configuration files are in place, start the DXP container with

    docker run -it --name dxp73  --add-host elasticsearch771: -p 8080:8080 -v $(pwd)/dxp:/mnt/liferay liferay/dxp:7.3.10-ga1
  3. Checkpoint: Verify that the Elasticsearch connection is active in Control Panel → Configuration → Search.

    An active connection is displayed in the Search administrative panel.

Re-index your search and spell check indexes. Both re-index actions are carried out from the Index Actions tab of Control Panel → Configuration → Search.

Additional Information