Skip to content

Instantly share code, notes, and snippets.

@hkrishna
Last active August 29, 2015 14:20
Show Gist options
  • Save hkrishna/727f3db3b8cc7442b83e to your computer and use it in GitHub Desktop.
Save hkrishna/727f3db3b8cc7442b83e to your computer and use it in GitHub Desktop.
Categories Aggregation query
# get the number of distinct category values in the index
curl -XGET "http://localhost:9200/pelias/_search?search_type=count" -d'
{
"aggs": {
"categories": {
"cardinality": {
"field": "category"
}
}
}
}'
# get the number of documents for each category
curl -XGET "http://localhost:9200/pelias/_search?search_type=count" -d'
{
"aggs": {
"categories": {
"terms": {
"field": "category",
"size": 107
}
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment