gpt4 book ai didi

elasticsearch - Elasticsearch中的Function_score,multi_match,script_score和filter

转载 作者:行者123 更新时间:2023-12-03 01:39:38 28 4
gpt4 key购买 nike

我在向嵌入在function_score内的现有多重匹配查询中添加过滤器时遇到问题。

理想情况下,我想按"term" : { "lang" : "en" }进行过滤,只获取英语版本的文档。

我尝试移动订单,尝试将查询包装在bool中,但是无法使过滤器与我正在使用的其他功能一起使用。

我的查询代码:

GET /my_index/_search/
{
"query": {
"function_score": {
"query": {
"bool": {
"filter": {
"term": {
"lang": "en"
}
},
"multi_match": {
"query": "Sample Query here",
"type": "most_fields",
"fields": [
"body",
"title",
"permalink",
"name"
]
}
}
},
"script_score": {
"script": {
"source": "_score + 10"
}
}
}
}
}

错误代码:
{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "[bool] query does not support [multi_match]",
"line": 11,
"col": 19
}
],
"type": "parsing_exception",
"reason": "[bool] query does not support [multi_match]",
"line": 11,
"col": 19
},
"status": 400
}

我正在使用最新版本的Elasticsearch(我相信是6.2)

最佳答案

尝试将multi_match包装在must子句中,如下所示

"must": {
"multi_match": ...
}

错误消息很清楚, bool查询仅接受 filtermustshould

关于elasticsearch - Elasticsearch中的Function_score,multi_match,script_score和filter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48893179/

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