This is an old revision of the document!
Table of Contents
Elasticsearch
The following assumes that elasticsearch is running on the localhost on port 9200.
General Info about elasticsearch instance
How is elasticsearch doing?
curl -XGET 'localhost:9200/_cat/health?v&pretty' curl -XGET 'localhost:9200/_cat/nodes?v’
What are the indices on this instance?
curl -XGET 'localhost:9200/_cat/indices?v&pretty’
Searching Data
Viewing Data
This will give you, by default, the first 20 results as prettified JSON
curl –XGET ‘localhost:9200/index/_search?pretty’
Sorting Examples
Search index
, matching all, and sorting by field
curl -XGET 'localhost:9200/index/_search?q=*&sort=field:asc&pretty’
Search index
, matching all, and sorting by field
curl -XGET 'localhost:9200/index/_search?pretty' -H 'Content-Type: application/json' -d’
{
"query": { "match_all": {} }, "sort": [ { "field": "asc" } ]
}'
Adding Information
Adding an index
curl -XPUT 'localhost:9200/newindex?pretty’
Inserting documents to an index
Insert the JSON document (after the -d) into the index with the id newid
:
curl –XPUT ‘localhost:9200/index/external/newid?pretty’ –d’{“field”:”data”}’