May 26, 2014

Elasticsearch: A cheatsheet of some basic cURL commands

Cheatsheet, with some useful links to either the Elasticsearch online manual, or other interesting reads.

Install Elasticsearch:
(check version here)
curl -L -O http://download.elasticsearch.org/PATH/TO/LATEST/$VERSION.zip
unzip elasticsearch-$VERSION.zip
cd  elasticsearch-$VERSION

Install Marvel:
(and turn off local cluster indexing)
./bin/plugin -i elasticsearch/marvel/latest
echo 'marvel.agent.enabled: false' >> ./config/elasticsearch.yml

Running Elasticsearch:
(add -d option to run in the background as a daemon)
./bin/elasticsearch
curl 'http://localhost:9200/?pretty'

Killing Elasticsearch Daemon:
# Shutdown local node
curl -XPOST 'http://localhost:9200/_cluster/nodes/_local/_shutdown'
# Shutdown all nodes in the cluster
curl -XPOST 'http://localhost:9200/_shutdown'

Create new empty Index:
curl -XPOST "http://localhost:9200/indexname"

Map out existing Indices and Types:
curl -XGET 'http://localhost:9200/_mapping?pretty'

Insert data over HTTP:
curl -XPOST "http://localhost:9200/indexname/typename/optionalUniqueId" -d '{ "field" : "value" }'

Retrieve data over HTTP (by ID):
curl "http://localhost:9200/indexname/typename/optionalUniqueId?pretty=true"

Retrieve data over HTTP (by search):
curl "http://localhost:9200/indexname/_search?pretty=true"

No comments :

Post a Comment