Indexing string as integer then getting back the integer value in search result

A team I am working with has a lot of dirty data. Sometimes a field might be a string, sometimes an integer for a particular field in several related Mongo collections. When it's a string, we can always rely on it being a valid integer, so these two work just fine:

PUT index/1
{
    "field": 1
}

PUT index/2
{
    "field": "2"
}

However, the _source field in the latter returns "field" as a string. Cleaning up the source data is not an option for me because it's outside of my authority. So is there a way to have ElasticSearch return "field" consistently as an integer or am I always going to be stuck with getting it back as whatever form it was indexed (integer or string)?

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