Elasticsearch is an open source, highly scalable, full-text search and analytics engine.
By default, Elasticsearch runs as an embedded search engine, which is useful for development and testing but is not supported in production. In production environments you must run Elasticsearch in remote mode, as a separate server or cluster. This guide walks you through the process of configuring Elasticsearch in remote mode.
If you’d rather use Solr, it’s also supported. See the documentation on Installing Solr if you’re interested.
To get up and running quickly with Elasticsearch as a remote server, refer to the Installing Elasticsearch article. Those are basic instructions for installing and configuring Elasticsearch in a single server environment. This article includes more details and information on clustering and tuning Elasticsearch. Here, you’ll learn to configure your existing Elasticsearch installation for use in production environments.
If you’ve come here looking for information on search engines in general, or the low level search infrastructure of Liferay DXP, refer instead to the developer tutorial Introduction to Liferay Search (not yet written).
These terms are useful to understand as you read this guide:
-
Elasticsearch Home refers to the root folder of your unzipped Elasticsearch installation (for example,
elasticsearch-6.5.1
). -
Liferay Home refers to the root folder of your Liferay DXP installation. It contains the
osgi
,deploy
,data
, andlicense
folders, among others.
Embedded vs. Remote Operation Mode
When you start Liferay DXP, this message is displayed in the log:
2018-12-10 16:20:32.987 WARN [Elasticsearch initialization thread][EmbeddedElasticsearchConnection:288] Liferay is configured to use embedded Elasticsearch as its search engine. Do NOT use embedded Elasticsearch in production. Embedded Elasticsearch is useful for development and demonstration purposes. Refer to the documentation for details on the limitations of embedded Elasticsearch. Remote Elasticsearch connections can be configured in the Control Panel.
When you install Liferay DXP, Elasticsearch is already embedded. In embedded mode, Elasticsearch search runs in the same JVM to make it easy to test-drive with minimal configuration. Running both servers in the same process has drawbacks:
- Elasticsearch must use the same JVM options as Liferay DXP.
- Liferay DXP and Elasticsearch compete for resources.
You wouldn’t run an embedded database like HSQL in production, and you shouldn’t run Elasticsearch in embedded mode in production either. Instead, run Elasticsearch in remote operation mode, as a standalone server or cluster of server nodes.
Troubleshooting Elasticsearch
Sometimes things don’t go as planned. If you’ve set up Liferay DXP with Elasticsearch in remote mode, but Liferay DXP can’t connect to Elasticsearch, check these things:
- Cluster name:
- The value of the
cluster.name
property in Elasticsearch must match theclusterName
property you configured for Liferay’s Elasticsearch adapter. - Transport address:
- The value of the
transportAddress
property in the Elasticsearch adapter must match the port where Elasticsearch is running. If Liferay DXP is running in embedded mode, and you start a standalone Elasticsearch node or cluster, it detects that port9300
is taken and switches to port9301
. If you then set Liferay’s Elasticsearch adapter to remote mode, it continues to look for Elasticsearch at the default port (9300
).
The following articles cover the Liferay Connector to Elasticsearch’s configuration options in more detail.