Nested query with decay function score fails with scaled_float type

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?

Do you have the stack trace from the Elasticsearch server logs for this error? That would help with determining if this is a bug.

There is nothing going into the server log on this error, all I'm getting is what is passed back to the client:

{"error":{"root_cause":[{"type":"parsing_exception","reason":"field [variants.x.labl] is of type [indexed,omitNorms], but only numeric types are supported.","line":1,"col":1}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"product_index","node":"oS4ixNR-S3Gc_LIaigTpGA","reason":{"type":"parsing_exception","reason":"field [variants.x.labl] is of type [indexed,omitNorms], but only numeric types are supported.","line":1,"col":1}}]},"status":400}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.