gpt4 book ai didi

elasticsearch - 如何使用MultiMatchQueryBuilder为每个字段设置提升?

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

multi_match查询通过json字段中的^符号支持字段增强,如下所示

{
"multi_match" : {
"query" : "this is the best",
"fields" : [ "number^5", "description^2" ]
}
}

我想使用Java api实现相同的功能,因此我使用 MultiMatchQueryBuilder构造查询,如下所示:
final MultiMatchQueryBuilder query
= new MultiMatchQueryBuilder(keyword, "number^5", "description^2");

但是 flex 搜索api会如下转换此查询:
{
"multi_match" : {
"query" : "this is the test",
"fields" : [
"number^5.0^1.0",
"description^2.0^1.0"
],
"type" : "best_fields",
"operator" : "OR",
"slop" : 0,
"prefix_length" : 0,
"max_expansions" : 50,
"lenient" : false,
"zero_terms_query" : "NONE",
"boost" : 1.0
}
}

为查询中的每个字段设置提升的正确方法应该是什么?

最佳答案

试试这个:

final MultiMatchQueryBuilder query
= new MultiMatchQueryBuilder(keyword).field("number",5).field("description",2);

关于elasticsearch - 如何使用MultiMatchQueryBuilder为每个字段设置提升?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46733353/

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