gpt4 book ai didi

elasticsearch - 如何增加agg结果列表的返回结果

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

我目前正在使用elasticsearch 6.4。
我使用aggs查询结果。详细信息如下。
对于某些查询语句,我没有得到想要的东西,而错过了我想要的文档。 flex 搜索似乎返回某种上限,以便返回某些顶部,而不是整个部分。因此有时我会缺少搜索结果中想要的东西。我目前怀疑这种效果是否与doc_count_error_upper_bound密切相关。我的猜测对吗?然后,如何在聚合过程中减少doc_count_error_upper_bound和sum_other_doc_count以获得我想要的?有什么方法可以调整值?

    q = {
"query": {
"bool": {
"must": {"query_string": {"default_field": "eLabel", "query": "Trump"}},
"must_not": [],
"should": []
}
},
"size": 0,
"_source": [
"eid"
],
"aggs": {
"eids": {
"terms": {
"field": "eid"
}
}
}

结果示例
{
"took": 21,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1103,
"max_score": 0,
"hits": [ ]
},
"aggregations": {
"eids": {
"doc_count_error_upper_bound": 15,
"sum_other_doc_count": 840,
"buckets": [
{
"key": "Q8684",
"doc_count": 62
}
,
{
"key": "Q1062177",
"doc_count": 36
}
,
{
"key": "Q100852",
"doc_count": 25
}
,
{
"key": "Q17469",
"doc_count": 25
}
,
{
"key": "Q39913",
"doc_count": 24
}
,
{
"key": "Q20398",
"doc_count": 22
}
,
{
"key": "Q157169",
"doc_count": 20
}
,
{
"key": "Q36929",
"doc_count": 17
}
,
{
"key": "Q17503",
"doc_count": 16
}
,
{
"key": "Q45086",
"doc_count": 16
}
]
}
}
}

最佳答案

这里的查询大小不适用于聚合,您必须在terms聚合内定义大小。

请找到以下查询以获得更多结果。

您可以在size中使用aggregation,但是在此处不能使用offset来检索数据,这意味着您只能更改限制。
假设您需要10个列表,之后需要下一个10个文档,则可以通过传递20号来获取下一个文档。

 {
"query": {
"bool": {
"must": {"query_string": {"default_field": "eLabel", "query": "Trump"}},
"must_not": [],
"should": []
}
},
"size": 0,
"_source": [
"eid"
],
"aggs": {
"eids": {
"terms": {
"field": "eid",
"size": 20
}
}
}

希望这对您有用。

关于elasticsearch - 如何增加agg结果列表的返回结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56439845/

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