# ES long field has string value indexed

**URL:** <https://discuss.elastic.co/t/es-long-field-has-string-value-indexed/161744>\
**Category:** Elasticsearch\
**Created:** [December 20, 2018, 6:18pm UTC](https://discuss.elastic.co/t/es-long-field-has-string-value-indexed/161744 "2018-12-20T18:18:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shrridevi\_sreedharan](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@shrridevi\_sreedharan](https://discuss.elastic.co/u/shrridevi_sreedharan)\
**Post date:** [December 20, 2018, 6:18pm UTC](https://discuss.elastic.co/t/es-long-field-has-string-value-indexed/161744/1 "2018-12-20T18:18:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [December 20, 2018, 6:31pm UTC](https://discuss.elastic.co/t/es-long-field-has-string-value-indexed/161744/2 "2018-12-20T18:31:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![shrridevi\_sreedharan](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@shrridevi\_sreedharan](https://discuss.elastic.co/u/shrridevi_sreedharan)\
**Post date:** [December 21, 2018, 3:49am UTC](https://discuss.elastic.co/t/es-long-field-has-string-value-indexed/161744/3 "2018-12-21T03:49:26Z")

</div>

> [@Igor\_Motov](#):
>
> cient history and unsafe to use. You

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.

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [December 21, 2018, 2:55pm UTC](https://discuss.elastic.co/t/es-long-field-has-string-value-indexed/161744/4 "2018-12-21T14:55:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 18, 2019, 2:55pm UTC](https://discuss.elastic.co/t/es-long-field-has-string-value-indexed/161744/5 "2019-01-18T14:55:17Z")

</div>

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