Personally, I'd use field boost because it feels more search-y. Say you boost title
10 compared to text
. It is still possible for something with a wonderful text match to outrank a poor title match. This comes up more if you happen to do both match_phrase
and match
at the same time. Like, if you have a boost on the match_phrase
so that phrase matches float to the top. Then, depending on the boost on the match_phrase
a phrase match in the text
can beat a regular match in the title
.
Yes. This mirrors a change in Lucene where boost was removed from queries a boost query was added to replace it.
That syntax working in multi_match
and query_string
queries and probably more I don't remember off the top of my head. Under the covers the those queries are building bool
queries and boost
queries.
The preference won't be hard and fast. If a term is twice as good a match against foo
its going to beat a half as good match of bar^2
. "Goodness" of a match is a bit complicated to explain though.
Its the default. Here are the docs for _sort
. If you don't send that field the default is sorting by score descending.
Probably. But its usually better to use score.
I suspect you'd do something like
{
"query": {
"function_score": {
"functions": {
"filter": {
"match": {"foo": "some text"},
"weight": 1
},
"filter": {
"match": {"bar": "some text"},
"weight": 2
}
}
"score_mode": "sum"
}
}
}
But that'd put all results that contained the bar match above the foo matches, all tied. Its probably not what you want, but you can play with it. I think its madness compared to just using field boosts, but if you want it, it is there for you. And it probably is the right thing to do in some rare situations.
function_score
is a query. "score functions" are the functions you can feed to it. They are the functions
field in the dsl of function_score
.
Sure. You can use the boosting query to make one of the must
or should
clauses strong than another one. You can use the ^
syntax on the field names if you are using multi_match
too.