Memos - Elasticsearch bash helper

Indexes

List indexes

curl -XGET "localhost:9200/_cat/indices?pretty"

Create an index

curl -XPOST "localhost:9200/samples?pretty"

Delete an index

curl -XDELETE "localhost:9200/samples?pretty"

Documents

List of 'samples' documents"

curl -XGET "localhost:9200/samples/_search?q=*&pretty"

Count 'samples' documents"

curl -XGET "localhost:9200/samples/_count"

Get a document

curl -XGET "localhost:9200/samples/external/uid?pretty"

Create a document

curl -XPOST "localhost:9200/samples/external?pretty" -d "{json}"

Set (update) a document

curl -XPOST "localhost:9200/samples/external/uid?pretty" -d "{json}"

Delete a document

curl -XDELETE "localhost:9200/samples/external/uis?pretty"

Bulk delete documents (new lines are important)

curl -XPOST "localhost:9200/samples/external/_bulk?pretty" -d '
{"delete":{"_id":"21"}}
{"delete":{"_id":"22"}}
{"delete":{"_id":"23"}}
'

Others

Get ELS version

curl -XGET "localhost:9200"

Read templates

curl -XGET "localhost:9200/_template/samples"

Put template

curl -XPUT "localhost:9200/_template/sample_prefix" -d "@/path/to/template.tpl"