I have a custom native scoring script (hamming distance), installed on an elasticsearch v2.3.1, and I'm applying it in my query like so:
curl -XPOST 'http://localhost:9200/myindex/_search?pretty' -d '{
"query": {
"function_score": {
"min_score": 14,
"query":{
"bool": {
"minimum_should_match": 6,
"should": [
{
"fuzzy": {
"myField0": {
"value": "10110110",
"fuzziness": 2
}
}
},
...
{
"fuzzy": {
"myField7": {
"value": "10010100",
"fuzziness": 2
}
}
}
]
}
},
"functions": [
{
"script_score": {
"script": "hamming_distance",
"lang" : "native",
"params": {
"param_hash": "myhash",
"param_field":"myField"
}
}
}
]
}
}
}'
The problem is that the scoring script is not being applied. If I change the query type to a filtered query, then it works - the scoring script is applied, but then I can't generate this query using the Java API because filteredQuery
is deprecated in favour of using boolQuery
s.
Can anyone advise what I should be doing? Should I be doing bools with filters nested or something? Thanks for any help!