Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Install and Configure Elasticsearch on OS X

Marcos Martinez edited this page Apr 20, 2016 · 10 revisions

Install the Elasticsearch search server, preferably using Homebrew:

brew install elasticsearch21

Modify the elasticsearch.yml file (in '/usr/local/etc/elasticsearch') to start Elasticsearch on the 'elasticsearch_cedar' cluster:

cluster.name: elasticsearch_cedar

Start Elasticsearch:

$ elasticsearch

Install Kibana and Sense. Sense is a handy console for interacting with the REST API of Elasticsearch. Sense is a Kibana app, so you will first need to install Kibana and then install Sense:

$ brew install kibana
$ kibana plugin --install elastic/sense

In order to start Kibana, just type:

$ kibana

You can access to Sense using your browser: http://localhost:5601/app/sense.

Configure Elasticsearch

Configure Elasticsearch to be used by the Value Recommender Server:

Use Sense to define a custom analyzer and apply it using a dynamic template. The default tokenizer used by Elasticsearch splits each string into individual words, but that default behavior is not appropriate for our value recommendation functionality. We need that the system recommends full values (e.g. "Longitudinal Study") instead of splitting them into individual words (e.g. "Longitudinal", "Study"). We use the keyword tokenizer to output exactly the same string as it received, without any tokenization. The lowercase filter normalizes the text to lower case. We also use a dynamic template to apply our custom analyzer to all fields.

PUT /cedar
{
  "settings":{
     "index":{
        "analysis":{
           "analyzer":{
              "analyzer_keyword":{
                 "tokenizer":"keyword",
                 "filter":"lowercase"
              }
           }
        }
     }
  },
  "mappings": {
    "template_instances": {
      "dynamic_templates": [
        {
          "my_template": {
            "match": "*",
            "match_mapping_type": "string",
            "mapping": {
              "type": "string",
              "analyzer":"analyzer_keyword"
            }
          }
        }
      ]
    }
  }
}

I you need to index some template instances to be used by the Value Recommender Server, use the following cluster, index and type:

  • Cluster: elasticsearch_cedar
  • Index: cedar
  • Type: template_instances

Some useful queries:

Cluster health: GET _cluster/health

List all indices: GET _cat/indices/?v

Get all types and instances: GET _mapping

Get all documents in a given index, of a particular type: GET {cluster_name}/{index_name}/_search Example: GET cedar/template_instances/_search

Delete an index: DELETE {index_name} Example: DELETE cedar

Clone this wiki locally