Created
February 4, 2019 09:59
-
-
Save siddharthlatest/f7a73eb10948982c1ee3f5aff855eda2 to your computer and use it in GitHub Desktop.
An ElasticSearch Aggregation example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl --location --request POST "https://scalr.api.appbase.io/RESTAPI/users/_search" \ | |
--header "Authorization: Basic YjdqV2hVSjhYOjcyYmI2ZmMxLWRkZjItNDU5Zi1iNGM3LWU2NzgwNjQyM2MyZA==" \ | |
--header "Content-Type: application/json" \ | |
--data '{ | |
"size": 0, | |
"aggs": { | |
"my-terms-agg": { | |
"terms": { | |
"field": "name" | |
} | |
} | |
} | |
}' | |
// This is a term aggregation which returns a response as follows: | |
// Read more about it at the link here - https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html | |
{ | |
"took" : 6, | |
"timed_out" : false, | |
"_shards" : { | |
"total" : 1, | |
"successful" : 1, | |
"failed" : 0 | |
}, | |
"hits" : { | |
"total" : 15, | |
"max_score" : 0.0, | |
"hits" : [ ] | |
}, | |
"aggregations" : { | |
"my-terms-agg" : { | |
"doc_count_error_upper_bound" : 0, | |
"sum_other_doc_count" : 0, | |
"buckets" : [ { | |
"key" : "appbase.io", | |
"doc_count" : 13 | |
} ] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment