Skip to content

Instantly share code, notes, and snippets.

@gizemabali
Last active January 30, 2020 11:25
Show Gist options
  • Save gizemabali/db6e6ed047fd5d2d9d30f7dd5c25f7c0 to your computer and use it in GitHub Desktop.
Save gizemabali/db6e6ed047fd5d2d9d30f7dd5c25f7c0 to your computer and use it in GitHub Desktop.
>> list indices
curl -X GET "localhost:9200/_cat/indices?v"
>> show elasticsearch health
curl -s -X GET 'http://localhost:9200/_cluster/health/'
>> delete index
curl -XDELETE http://localhost:9200/index_name/
>> ask document count
curl -XGET 'http://localhost:9200/index_name/_count?pretty=true'
>> search documents
curl 'http://localhost:9200/index_name/_search?q=*'
curl 'http://localhost:9200/index_name/_search?pretty'
>> show index mapping
curl -XGET 'http://localhost:9200/index_name/_mapping?pretty=true'
>> search with key
curl -XGET -H 'Content-Type: application/json' 'http://localhost:9200/index_name/_search' -d '
{
"query": {
"match": {"key_id": "value"}}
}
}
'
>> search and sort all
curl -XGET -H 'Content-Type: application/json' 'http://localhost:9200/index_name/_search' -d '
{
"query": {
"match_all": {}
},
"sort" : {
"timestamp": {"order": "asc"}
}
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment