Aggregating nested fields of varying datatypes in Elasticsearch
You need a mapping like this one, for the value
field:
"value": { "type": "string", "fields": { "as_number": { "type": "integer", "ignore_malformed": true } } }
Basically, your field is string
but using fields
you can attempt to format it as a numeric field.
When you want to use range
queries then use value.as_number
, for anything else use value
.