# Fields with same name mapped differently in different types

**URL:** <https://discuss.elastic.co/t/fields-with-same-name-mapped-differently-in-different-types/16261>\
**Category:** Elasticsearch\
**Created:** [March 10, 2014, 12:51pm UTC](https://discuss.elastic.co/t/fields-with-same-name-mapped-differently-in-different-types/16261 "2014-03-10T12:51:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![morninlark](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@morninlark](https://discuss.elastic.co/u/morninlark)\
**Post date:** [March 10, 2014, 12:51pm UTC](https://discuss.elastic.co/t/fields-with-same-name-mapped-differently-in-different-types/16261/1 "2014-03-10T12:51:10Z")

</div>

Hey there,

I have one index containing various types. It does happen, that a field with the same name is mapped as string in one type and as integer in another type.

The following query on a type t1, where "sample\_field" is mapped as string  
{  
"query": {  
"match\_all": {}  
},  
"facets": {  
"stats": {  
"statistical": {  
"field": "sample\_field"  
}  
}  
}  
}

results in:  
=\> FacetPhaseExecutionException[Facet [stats]: field [sample\_field] isn't a number field, but a string]  
which is of course the expected feedback

The same query a type t2, where "sample\_field" is mapped as integer, leads to the following error:  
=\> NumberFormatException[Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]

I know I could either rename the fields or put the types in different indexes to avoid this error.  
I want to keep the mappings as they are.  
Is there a more elegant way to solve this issue?

I am using elasticsearch version 0.90.7

Thank you!

---

<div class="post-metadata">

**Author:** ![morninlark](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@morninlark](https://discuss.elastic.co/u/morninlark)\
**Post date:** [March 10, 2014, 2:47pm UTC](https://discuss.elastic.co/t/fields-with-same-name-mapped-differently-in-different-types/16261/2 "2014-03-10T14:47:28Z")

</div>

I also tried it with  
{  
"query": {  
"match\_all": {}  
},  
"facets": {  
"t2.stats": {  
"statistical": {  
"field": "t2.sample\_field"  
}  
}  
}  
}  
but that results in the same error message.

---

<div class="post-metadata">

**Author:** ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)\
**Post date:** [March 10, 2014, 4:31pm UTC](https://discuss.elastic.co/t/fields-with-same-name-mapped-differently-in-different-types/16261/3 "2014-03-10T16:31:30Z")

</div>

Unfortunately, no you can't do this at the moment. You'd have to make all  
your field types the same, or use different field names. If they are all in  
the same index in different types with different data types and same field  
names, you'll unfortunately encounter this limitation.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e0c06fab-1cba-4c89-8861-e905f6a8338f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e0c06fab-1cba-4c89-8861-e905f6a8338f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![morninlark](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@morninlark](https://discuss.elastic.co/u/morninlark)\
**Post date:** [March 10, 2014, 5:21pm UTC](https://discuss.elastic.co/t/fields-with-same-name-mapped-differently-in-different-types/16261/4 "2014-03-10T17:21:16Z")

</div>

Thank you for your answer.  
Renaming would create other problems for me, so I went with putting the types in different indexes.

---

<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:** [July 6, 2017, 1:44am UTC](https://discuss.elastic.co/t/fields-with-same-name-mapped-differently-in-different-types/16261/5 "2017-07-06T01:44:29Z")

</div>


