The multi_match query supports field boosting via ^ notation in the json field as below
{
"multi_match" : {
"query" : "this is the best",
"fields" : [ "number^5", "description^2" ]
}
}
I want to achieve the same using java api, thus I am using MultiMatchQueryBuilder
to construct the query as below:
final MultiMatchQueryBuilder query
= new MultiMatchQueryBuilder(keyword, "number^5", "description^2");
But elastic search api is converting this query as below:
{
"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
}
}
What should be the correct way to set boost for each fields from the query?
Try this:
final MultiMatchQueryBuilder query
= new MultiMatchQueryBuilder(keyword).field("number",5).field("description",2);