gpt4 book ai didi

elasticsearch - Elasticsearch 2.0.0中的采样器聚合

转载 作者:行者123 更新时间:2023-12-03 00:18:45 25 4
gpt4 key购买 nike

{
"query": {
"match": {
"text": query
}
},
"size": 5,
"aggs": {
"bestDocs": {
"sampler": {
"field": "cluster",
"shard_size": 1
},
"aggs": {
"bestBuckets": {
"terms": {
"field": "cluster",
"size": 5
}
}
}
}
}
}

使用简单查询,我得到了一堆文档,其中每个文档都有一个 bucket id。我正在尝试使用采样器聚合来按其在常规查询中出现的顺序获取存储区ID。

但是,当我运行上述查询时,我会按升序获得存储桶,而这些存储桶甚至不是我从常规查询中获得的存储桶。

例如。
{
"took": 4,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 959,
"max_score": 1.841992,
"hits": [
{
"_source": {
"cluster": "22570",
"text": "about 1.5 million veteran families live at the federal poverty level, including 634,000 below 50 percent of the federal poverty",
}
},
{
"_source": {
"cluster": "22570",
"text": "about 1.5 million veteran families live at the federal poverty level, including 634,000 below 50 percent of the federal poverty",
}
},
{
"_source": {
"cluster": "22570",
"text": "about 1.5 million veteran families live at the federal poverty level, including 634,000 below 50 percent of the federal poverty",
}
},
{
"_source": {
"cluster": "22570",
"text": "about 1.5 million veteran families live at the federal poverty level, including 634,000 below 50 percent of the federal poverty",
}
},
{
"_source": {
"cluster": "12239",
"text": "veterans and their families.&quot;</p><p>The Veterans&#39; Compensation Cost-of-Living Adjustment Act of 2011 directs the Secretary of Veterans Affairs to increase the rates of veterans",
}
}
]
},
"aggregations": {
"bestDocs": {
"doc_count": 5,
"bestBuckets": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": 22185,
"doc_count": 1
},
{
"key": 22570,
"doc_count": 1
},
{
"key": 29615,
"doc_count": 1
},
{
"key": 32784,
"doc_count": 1
},
{
"key": 43351,
"doc_count": 1
}
]
}
}
}
}

您可以看到聚合不是必需的。如何按顺序获取 [22570, 12239]

最佳答案

"sampler": {
"field": "cluster",
"shard_size": 1 // <-- It could be the potential culprit
},

ID 22570, 12239可能都属于同一个分片。当您将分片大小指定为1时,聚合可能仅从该分片中获得一个,这是因为聚合中省略了 12239

关于elasticsearch - Elasticsearch 2.0.0中的采样器聚合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33406557/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com