Hi, running the ELK stack on the Elastic cloud, I've defined a search template that has the following query:
"query": {
"function_score": {
"functions": [
{
"field_value_factor": {
"field": "marketcap",
"missing": 1,
"modifier": "log1p"
}
}
],
"query": {
"bool": {
"should": [
{
"multi_match": {
"fields": [
"name",
"symbol^3"
],
"query": "{{query_string}}",
"type": "phrase_prefix"
}
},
{
"multi_match": {
"fields": [
"name"
],
"fuzziness": "auto",
"query": "{{query_string}}"
}
},
{
"match_phrase": {
"symbol": {
"boost": 3,
"query": "{{query_string}}"
}
}
},
]
}
}
}
}
which scores the name and symbol fields of the document, and then adds score according to the field marketcap, in the form of math's log function.
I want to add a filter on field isEnabled so only documents with value true gets returned.
I tried adding it to the bool clause, under must, but then, the function_score gets applied to all of the documents, and not only to the results in the should clause (which makes sense).
how can get the desired result, which is filtering out all documents with isEnabled set to false but only use the marketcap score on the results of the should clause?
thanks!