Here is the guts of a nested function score query, which works:
"query": {
"function_score": {
"field_value_factor": {
"field": "variants.x.laba",
},
"query": {
"bool": {
"must": [
...
],
}
}
However, if the scoring function is changed to any of the decay functions (gauss, exp, linear), it fails. The failing query looks like:
"query": {
"function_score": {
"gauss": {
"variants.x.laba": {
"origin": 100,
"scale": 202.3,
},
},
"query": {
"bool": {
"must": [
...
],
}
}
and it fails with the error:
elasticsearch.exceptions.RequestError: TransportError(400, 'search_phase_execution_exception', 'field [variants.x.laba] is of type [indexed,omitNorms], but only numeric types are supported.')
but the type mapping is numeric (scaled float); here is a verbatim extract from GET _mappings:
"x" : {
"type" : "nested",
"properties" : {
"laba" : {
"type" : "scaled_float",
"scaling_factor" : 1000.0
},
So it is a numeric field, the same field works correctly with field_value_factor.
I have tried ES versions 5.5.3 and 5.6.3. I have tried making the origin and scale parameters strings (as in the examples).
During the course of writing this post I tried changing the field to a plain float type and that fixed the problem.
A bug? Or have I missed something?