ericjarvies
12/11/2016 - 1:53 PM

elasticsearch curl

elasticsearch curl

cluster;

curl http://localhost:9200

cluster state (&pretty for nicer display);

curl http://localhost:9200/_cluster/state?pretty

cluster settings (&pretty for nicer display);

curl http://localhost:9200/_cluster/settings?pretty

cluster health (add ?v for verbose and &pretty for nicer display);

curl http://localhost:9200/_cat/health

cluster nodes (add ?v for verbose and &pretty for nicer display);

curl http://localhost:9200/_cat/nodes

cluster machine-specific node;

curl http://localhost:9200/_nodes/_local?pretty

cluster specific or name (tor) or range (.*) or list (10.0.0.1,10.0.0.2) of nodes;

curl http://10.0.0.1:9200/_nodes/10.0.0.*?pretty

cluster nodes stats (all);

curl -XGET 'http://localhost:9200/_nodes/stats'

cluster nodes stats (specific);

curl -XGET 'http://localhost:9200/_nodes/nodeId1,nodeId2/stats'

cluster nodes stats (indices and os);

curl -XGET 'http://localhost:9200/_nodes/stats/os'

cluster nodes stats (os and process);

curl -XGET 'http://localhost:9200/_nodes/stats/os,process'

cluster nodes stats (specific type endpoint);

curl -XGET 'http://localhost:9200/_nodes/stats/process'

cluster nodes stats (specific type endpoint);

curl -XGET 'http://localhost:9200/_nodes/10.0.0.1/stats/process'

cluster shards (add ?v for verbose and &pretty for nicer display);

curl http://localhost:9200/_cat/shards

cluster indices (add ?v for verbose and &pretty for nicer display);

curl http://localhost:9200/_cat/indices

cluster segments (add ?v for verbose and &pretty for nicer display);

curl http://localhost:9200/_cat/segments

set number of replicas;

curl -XPUT http://localhost:9200/_settings -d'{"number_of_replicas":1}'

create an index;

curl -XPUT 'http://localhost:9200/customer?pretty'

delete an index;

curl -XDELETE 'http://localhost:9200/customer?&pretty'

add document to index;

curl -XPUT 'http://localhost:9200/customer/external/1?&pretty' -d'{"name": "John Doe"}'

retreive document in index;

curl -XGET 'http://localhost:9200/customer/external/1?&pretty'

update document in index (updates document "1" & +1 version);

curl -XPOST 'http://localhost:9200/customer/external/1/_update?&pretty' -d'{"doc": { "name": "Jane Doe" }}'

update document in index (updates document "1" & increments version & add new field);

curl -XPOST 'http://localhost:9200/customer/external/1/_update?pretty&pretty' -d'{"doc": { "name": "Jane Doe", "age": 20 }}'

curl -XDELETE 'http://localhost:9200/customer/external/2?&pretty'

curl -XPOST 'http://localhost:9200/customer/external/_bulk?&pretty' -d' {"index":{"_id":"1"}} {"name": "John Doe" } {"index":{"_id":"2"}} {"name": "Jane Doe" }'

curl -XPOST 'http://localhost:9200/customer/external/_bulk?&pretty' -d' {"update":{"_id":"1"}} {"doc": { "name": "John Doe becomes Jane Doe" } } {"delete":{"_id":"2"}}'

curl -XGET 'http://localhost:9200/bank/_search?q=*&sort=account_number:asc&pretty'

curl -XGET 'localhost:9200/bank/_search?pretty' -d' { "query": { "match_all": {} }, "sort": [ { "account_number": "asc" } ] }'