ES long field has string value indexed

I am using ES 1.7 version and have a field mapped as long. But I see the data for that field however is stored as string. How can i query the data for such mismatched types. I need to search for that field with a specific value on all indexes.

I tried with wildcard index search with team query on that field. It resulted in 0 hits. But the same term query gives result if the field is prefixed with the _type.

I am not quite sure what you mean when you say "that field however is stored as string." Do you mean it has a numeric value in a string ("foo": "123456") or it's some non-numeric text ("foo": "barbaz").

BTW, 1.7 is ancient history and unsafe to use. You should really consider switching to a more modern version of elasticsearch.

Thanks a lot for taking a look at this.
The field has the value stored as numerical string as "foo": "123456". The field "foo" has mapping set as long type. Unfortunately we cannot upgrade the version at this point of time.

_index: transaction
_type: partc

The below does not work:
curl -X POST "localhost:9200/*/_search" -H 'Content-Type: application/json' -d'
{
"query": {
"term" : { "foo" : "123456" }
}
}
'

But if I query with the _type, I get the result as below.
curl -X POST "localhost:9200/*/_search" -H 'Content-Type: application/json' -d'
{
"query": {
"term" : { "partc/foo" : "123456" }
}
}
'

How can I search the same without specifying the _type. Because its a wildcard search across all indexes.

Sorry, I don't understand what you are trying to do. Could you show a complete example with mapping and test data in it?

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