Elasticsearch 2 Data Store

Introduction

To use the Trends panel and to see the experiment servings, visits must be stored in Elasticsearch.

Hippo DX 11.2 supports Elasticsearch versions 2 and 5. This page describes how to configure an Elasticsearch 2 data store. To configure an Elasticsearch 5 data store, see Elasticsearch 5 Data Store.

Install Elasticsearch

Download and install Elasticsearch 2.

For guidance on installing, configuring, deploying and administering Elasticsearch please refer to the Elasticsearch documentation. Hippo does not require any special or additional steps to set up Elasticsearch. For production environments we recommend a cluster of at least two Elasticsearch nodes for high availability.

Configure Visits Data Store

A Relevance Elasticsearch Data Store connects to its database through a JNDI data source lookup which needs to be defined on container level, e.g. Apache Tomcat.

Add the following environment entry in conf/context.xml in your project:

<Environment
  name="elasticsearch/targetingDS"
  type="java.lang.String"
  value="{'indexName':'your-index', 'locations':['url-1','url-2]',...]}" />

This will register a JNDI environment resource under java/comp:env/elasticsearch/targetingDS when the site web application is started. The JSON string contains the properties needed to instantiate a client that can connect to an Elasticsearch cluster.

Change 'your-index' to the name of your index. Change ['url-1','url-2]',...] to the list of the URLs of your Elasticsearch cluster nodes. For local development, you can set locations to ['http://localhost:9200']'.

The table below lists all available JSON fields:

Field

Type

Default 

Description

indexName (*)

String 

n/a

The name of the Elasticsearch index (roughly equivalent to a database in a RDBMS).

locations (*)

String array

n/a

URL locations of nodes in the Elasticsearch cluster to connect to. One location is enough to connect to the cluster. Specifying multiple locations adds robustness for the startup process.

Username

String

n/a

Optional. username for if elasticsearch requires authenticated access.
password

String

n/a

Optional. Password for if elasticsearch requires authenticated access.

maxConnections

Long 

20

Optional. Maximum number of client threads in the connection pool that will be used to connect to Elasticsearch.
timeToLiveSeconds Long n/a Optional. How long items stored by this store should be kept, in seconds. Default is infinite or value set as default in Elasticsearch

(*) = required

This JNDI environment resource must be configured for the visits store, like below default bootstrapped configuration:

/targeting:targeting/targeting:datastores/targeting:visits
  - targeting:storefactoryclass =
      com.onehippo.cms7.targeting.storage.elastic2.ElasticStoreFactory
  - dataSource = elasticsearch/targetingDS

Configure Elasticsearch

Create the index configured above (referred to by the indexName property) in Elasticsearch, e.g. using curl:

curl -s -S -XPUT http://elastic.host:9200/indexname

The index must be accessible for reading and writing to the users as configured by the authentication property.  How this can be done is out of scope of this document because it depends on the deployment scenario of your Elasticsearch instance. Please consult your administrator to find out how you can create the index in your Elasticsearch instance.

Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?