In our current set-up we use a function_score in combination with a native Java plugin to calculate the price of lease cars. I would like to add a not filter around it. Currently it looks something like this:
"query": {
"filtered": {
"filter": {
"not": {
"term": {
"make.facet": "Audi"
}
}
},
"query": {
"function_score": {
"functions": [
{
"script_score": {
"script": "native-score",
"lang": "native",
"params": {...}
}
}
],
"query": {
"match_all": {}
},
"boost_mode": "replace",
"min_score": 0
}
}
}
}
The problem I am having though is that for the filtered documents the plugin is still called, but without the expected fields. Right now I have solved this with a dirty check in the plugin to see if any of the required fields are set, and if not I simply return null
to prevent ending up with NPE's. Surely this isn't the best way to fix this. We are using elasticsearch 1.7.5. Is this a bug, or can I re-organize my query in such a way that it works as expected?