I've got data being ingested into Elasticsearch which arrives in the incoming JSON as a string containing a floating point number, eg
"myfield": "1234.56"
So I've set a mapping for it
"myfield": { "type": "double" }
expecting then to be able to process it as numeric. And, indeed, after a mapping refresh, Kibana now believes this is a numeric field and appears to do numeric things with it, such as being able to display graphs of the value of this field. All good so far.
But if I do a search it comes back as a string
"_source": { "myfield": "1234.56" }
not as a number
"_source": { "myfield": 1234.56 }
which is what I would like for further processing of the search results in another language.
So what's going on here? If setting a mapping doesn't work, how do I get this field to be returned from a search as the correct type, if we take it as given that the software (several steps up the line) which generates the original JSON doesn't know about anything other than strings?
The _source that Elasticsearch returns is always the original document that you sent it. Even though Elasticsearch will internally treat that field as a double when running searches and aggregations, what gets returned as the _source is the original document.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.