gpt4 book ai didi

elasticsearch - 在ElasticSearch中按子频率过滤

转载 作者:行者123 更新时间:2023-12-02 22:52:34 25 4
gpt4 key购买 nike

我目前在 flex 搜索(文档)和与这些文档相关的 child (评论)中为 parent 编制了索引。
我的第一个目标是根据子查询来搜索包含N条以上注释的文档。这是我的做法:

documents/document/_search
{
"min_score": 0,
"query": {
"has_child" : {
"type" : "comment",
"score_type" : "sum",
"boost": 1,
"query" : {
"range": {
"date": {
"lte": 20130204,
"gte": 20130201,
"boost": 1
}
}
}
}
}
}

我使用了分数来计算文档的评论数量,然后使用“min_score”按照该数量过滤文档。
现在,我的目标不仅是搜索注释,还总是根据频率搜索与该文档相关的其他几个子文档。像查询波纹管这样的东西:
documents/document/_search
{
"query": {
"match_all": {
}
},
"filter" : {
"and" : [{
"query": {
"has_child" : {
"type" : "comment",
"query" : {
"range": {
"date": {
"lte": 20130204,
"gte": 20130201
}
}
}
}
}
},
{
"or" : [
{"query": {
"has_child" : {
"type" : "comment",
"query" : {
"match": {
"text": "Finally"
}
}
}
}
},
{ "query": {
"has_child" : {
"type" : "comment",
"query" : {
"match": {
"text": "several"
}
}
}
}
}
]
}
]
}
}

上面的查询工作正常,但它不像第一个查询那样基于频率进行过滤。由于过滤器是在计算分数之前计算的,因此我无法使用min_score过滤每个子查询。

这个问题有解决方案吗?

最佳答案

没有与过滤器相关的分数。我建议将整个逻辑移至查询部分,并使用bool query将不同的查询组合在一起。

关于elasticsearch - 在ElasticSearch中按子频率过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19440152/

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