ElasticSearch aggs returns 仅 10 个桶
ElasticSearch aggs returns 10 buckets only
我是 运行 一个 aggs 查询并指定大小为 100,但 ES 只返回 returns 10 个桶。为什么?我错过了什么?
{
"size": 100
,"query": {
"bool": {
"must": [
{ "term": {"app": "cnn"} }
]
}
}
,"aggs": {
"unique_client": {
"terms": {"field": "client"}
}
}
}
outer size 是你为查询返回的文档总数,所以 size = 100 returns 100 个文档,为了得到 100 个聚合桶,指定大小在 你的 unique_client 像这样
{
"size": 0
,"query": {
"bool": {
"must": [
{ "term": {"app": "cnn"} }
]
}
}
,"aggs": {
"unique_client": {
"terms": {"field": "client"},
"size" : 100
}
}
}
聚合的默认大小为 10,这就是为什么您会得到 10 个结果,我将外部大小设置为 0 以仅获取聚合。
将 top size 参数设置为零以表示它是一个聚合。返回的桶数通过在术语聚合括号内指定大小来设置。
{
"size": 0
,"query": {
"bool": {
"must": [
{ "term": {"app": "cnn"} }
]
}
}
,"aggs": {
"unique_client": {
"terms": {
"field": "client",
"size" : 100
}
}
}
}
如果将其设置为 0,该值将默认为 Integer.MAX_VALUE
我是 运行 一个 aggs 查询并指定大小为 100,但 ES 只返回 returns 10 个桶。为什么?我错过了什么?
{
"size": 100
,"query": {
"bool": {
"must": [
{ "term": {"app": "cnn"} }
]
}
}
,"aggs": {
"unique_client": {
"terms": {"field": "client"}
}
}
}
outer size 是你为查询返回的文档总数,所以 size = 100 returns 100 个文档,为了得到 100 个聚合桶,指定大小在 你的 unique_client 像这样
{
"size": 0
,"query": {
"bool": {
"must": [
{ "term": {"app": "cnn"} }
]
}
}
,"aggs": {
"unique_client": {
"terms": {"field": "client"},
"size" : 100
}
}
}
聚合的默认大小为 10,这就是为什么您会得到 10 个结果,我将外部大小设置为 0 以仅获取聚合。
将 top size 参数设置为零以表示它是一个聚合。返回的桶数通过在术语聚合括号内指定大小来设置。
{
"size": 0
,"query": {
"bool": {
"must": [
{ "term": {"app": "cnn"} }
]
}
}
,"aggs": {
"unique_client": {
"terms": {
"field": "client",
"size" : 100
}
}
}
}
如果将其设置为 0,该值将默认为 Integer.MAX_VALUE