Closed
Description
Rescore implementation currently only support a single query. When you use the fluent API you can only add a single rescore query. If you add multiple queries, a single one will be added.
Easy repro:
// NameScoreFunction its just a customer FunctionScoreFunctionBase implementation
var searchresults =
client.Search<Session>(q => q
.Query(mainQuery)
.Rescore(r => r.RescoreQuery(rq => rq
.Query(qq => qq
.FunctionScore(fs => fs
.Functions(new[] { new NameScoreFunction() { QueryName = "fullname", Field = "fullName" } })
))
.QueryWeight(0)
.RescoreQueryWeight(1))
.WindowSize(200)
)
.Rescore(r2 => r2
.RescoreQuery(rq => rq
.Query(qq => qq
.FunctionScore(fs => fs
.Functions(new[] { new NameScoreFunction() { QueryName = "company name", Field = "companyNames" }
})))
.QueryWeight(.5)
.RescoreQueryWeight(.5))
.WindowSize(200)));
The result of this is the following:
{
"rescore": {
"window_size": 200,
"query": {
"rescore_query": {
"function_score": {
"functions": [{
"name_score": {
"field": "companyNames",
"query_name": "company name"
}
}]
}
},
"query_weight": 0.5,
"rescore_query_weight": 0.5
}
},
"query": {
"match": {
"primary_name": {
"query": "Joe Shmo"
}
}
}
}
Note that the field is companyNames
which comes from the second rescore query.
Metadata
Metadata
Assignees
Labels
No labels