gpt4 book ai didi

elasticsearch - Elasticsearch在聚合中指定索引过滤器

转载 作者:行者123 更新时间:2023-12-03 01:33:23 25 4
gpt4 key购买 nike

我有一个 flex 查询聚合,其中我需要根据索引名称过滤聚合。查询部分实际上在多个索引上工作,但是我想过滤特定索引的聚合。请帮助我如何在聚合中通过索引过滤器-

{       
"query": {
"bool": {
"filter": [
{
"bool": {
"should": [
{
"query_string": {
"fields": [
"productDesc",
"productDescription"
],
"default_operator": "AND",
"query": "machine"
}
}
]
}
}
],
"must": [ ],
"must_not": [ ]
}
},
"size": 0,
"aggs": {
"RelatedKeywords": { //here I want to add filter of index
"sampler": {
"shard_size": 20
},
"aggregations": {
"keywords": {
"significant_text": {
"field": "productDesc",
"size": 100,
"filter_duplicate_text": true
}
}
}
}
}
}

最佳答案

您可以这样做:

{
"aggs": {
"index": {
"filter": {
"term": {
"_index": "index-name"
}
},
"aggs": {
"RelatedKeywords": {
"sampler": {
"shard_size": 20
},
"aggregations": {
"keywords": {
"significant_text": {
"field": "productDesc",
"size": 100,
"filter_duplicate_text": true
}
}
}
}
}
}
}
}

关于elasticsearch - Elasticsearch在聚合中指定索引过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54568300/

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