https://blog.csdn.net/qq_25834767/article/details/84642051
https://blog.csdn.net/fz13768884254/article/details/86075714
{ 'query': { 'bool': { 'must': { 'term': {'myip': ''} }, 'filter': { 'range': {'': {'gte': , 'lt': }} } } } }
{ 'query': { 'range': { '$KEY': { 'gte': , 'lt': , } } }, 'aggs': { '$AGG_NAME': { 'terms': { 'field': '' } } }, size: 0 }
注意:
如果聚合时被提示字段类型是text,则需要在字段后加 .keyword,例如key是 myip,则 'field': 'myip.keyword'
参考:https://www.jianshu.com/p/26744eb914a8
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html#return-only-agg-results
查询对象中设置 size 为 0
{ "size": 0, "aggs": { "my-agg-name": { "terms": { "field": "my-field" } } } }