GET /index/_search
GET /megacorp/_search
{
"aggs": {
"NAME": {
"AGG_TYPE": {}
}
}
}
GET /megacorp/_search
{
"aggs": {
"employee age sum": {
"sum": {
"field": "age"
}
}
}
}
GET /megacorp/_search
{
"aggs": {
"all_interests": {
"terms": {
"field": "interests.keyword",
"size": 1
}
}
}
}
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
// 忽略...
},
"aggregations" : {
"all_interests" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "music",
"doc_count" : 2
}
]
}
}
}
GET /megacorp/_search
{
"aggs": {
"filter aggs": {
"filter": {
"term": {
"last_name.keyword": "Fir"
}
}
}
}
}
GET /megacorp/_search
{
"aggs": {
"top_hits ": {
"top_hits": {
"size": 1
}
}
}
}
GET /megacorp/_search
{
"aggs": {
"NAME": {
"geo_distance": {
"field": "location",
"origin": {
"lat": 52.376,
"lon": 4.894
},
"ranges": [
{
"from": 100,
"to": 300
}
]
}
}
}
}
GET /megacorp/_search
{
"aggs": {
"all interests": {
"terms": {
"field": "interests.keyword",
"size": 1
}
},
"employee age max": {
"max": {
"field": "age"
}
}
}
}