Elasticsearch

From ArchWiki
Jump to: navigation, search

From Wikipedia:Elasticsearch:

Elasticsearch is a search engine based on Lucene. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents. Elasticsearch is developed in Java and is released as open source under the terms of the Apache License.

Installation

Elasticsearch requires at least OpenJDK 7, see Java.

Install the elasticsearch package.

Running

Start/enable elasticsearch.service.

Ensure Elasticsearch is running and accessible by using curl, curl -X GET '<protocol>://<host>:<port>':

curl -X GET http://127.0.0.1:9200
{
  "name" : "Sunder",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "*cluster-uuid*",
  "version" : {
    "number" : "2.4.1",
    "build_hash" : "c67dc32e24162035d18d6fe1e952c4cbcbe79d16",
    "build_timestamp" : "2016-09-27T18:57:55Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.2"
  },
  "tagline" : "You Know, for Search"
}

Configuration

The main Elasticsearch configuration file is well-documented and located at /etc/elasticsearch/elasticsearch.yml.

  • By default Elasticsearch is public accessible, it may be preferred to allow only access on the host instead:
network.host: 127.0.0.1
  • It is possible to use a custom port instead of the default 9200:
http.port: 9200

You may want to change the default initial and maximum allowed memory usage:

/etc/elasticsearch/jvm.options
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms128m # e.g. 256m, 1g, 2g, ..
-Xmx512m # e.g. 256m, 1g, 2g, ..
Note: Installing elasticsearch provides already an increased vm.max_map_count as in /usr/lib/sysctl.d/elasticsearch.conf.

You might need to update the vm.max_map_count system limit:

# sysctl -w vm.max_map_count=262144

Usage

Elasticsearch uses a REST API, see Wikipedia:RESTful API for more information.

Talking to Elasticsearch and the Getting started guide should provide you with basic and detailed usage information.

The Elasticsearch server management (document maintenance, performing search, etc.) is usually done by clients, that should provide a seamless integration with the preferred programming language.

Useful tools to manage ElasticSearch instances and clusters like ElasticHQ, Elasticsearch GUI, Kibana and Adminer are also available to simplify management.