I'm interested in any optimizations, but in particular, I want to ensure the score functions are only executed on documents that match at least one of the should clauses, not on all documents. Not sure whether that is the case as it is written now:
{
"body": {
"query": {
"function_score": {
"functions": [
...a bunch of functions
],
"boost_mode": "replace",
"query": {
"bool": {
"should": [
{
"match_phrase": {
"field 1": "query"
}
},
{
"match_phrase": {
"field 2": "query"
}
},
{
"match_phrase": {
"field 3": "query"
}
}
]
}
}
}
}
}
}
Elasticsearch >=2.1, in case it makes a difference.