# Different document types with shared field names

**URL:** <https://discuss.elastic.co/t/different-document-types-with-shared-field-names/11865>\
**Category:** Elasticsearch\
**Created:** [May 7, 2013, 10:01pm UTC](https://discuss.elastic.co/t/different-document-types-with-shared-field-names/11865 "2013-05-07T22:01:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christopher\_J\_Bottar](https://avatars.discourse-cdn.com/v4/letter/c/e0b2c6/32.png) [@Christopher\_J\_Bottar](https://discuss.elastic.co/u/Christopher_J_Bottar)\
**Post date:** [May 7, 2013, 10:01pm UTC](https://discuss.elastic.co/t/different-document-types-with-shared-field-names/11865/1 "2013-05-07T22:01:20Z")

</div>

I'm trying to understand this correctly. If I have two separate document  
types (my\_type\_1 and my\_type\_2), and they both have a field (my\_field)  
which is defined different (string not analyzed and long), I can't do a  
search on my\_type\_1 sorting by my\_field if there are any documents in the  
index of my\_type\_2 that have multiple values in my\_field?

Because of this, I have to prefix all my fields with the document type...  
which seems wrong. Am I missing something?

Thanks for the help.

References:

"Can't sort on string types with more than one value per doc, or more than  
one token per field"  
[http://elasticsearch-users.115913.n3.nabble.com/not-analyzed-attribute-gt-Can-t-sort-on-string-types-with-more-than-one-value-per-doc-or-more-than-od-td3848413.html](http://elasticsearch-users.115913.n3.nabble.com/not-analyzed-attribute-gt-Can-t-sort-on-string-types-with-more-than-one-value-per-doc-or-more-than-od-td3848413.html)

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![radu\_gheorghe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe/32/556_2.png) [@radu\_gheorghe](https://discuss.elastic.co/u/radu_gheorghe)\
**Post date:** [May 9, 2013, 7:33am UTC](https://discuss.elastic.co/t/different-document-types-with-shared-field-names/11865/2 "2013-05-09T07:33:55Z")

</div>

Hello Christopher,

You might be able to reference the specific field you want with something  
like my\_type\_1.my\_field, although it shouldn't work for faceting (source  
here [http://www.elasticsearch.org/guide/reference/mapping/](http://www.elasticsearch.org/guide/reference/mapping/)).

The reason for it is that all your fields from all your types end up in the  
same Lucene indices (shards), so if you have the same field name in  
multiple types, it's best to have the same settings. Otherwise, you'll bump  
into the behavior you're reporting here.

## Best regards, Radu

[http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

On Wed, May 8, 2013 at 1:01 AM, Christopher J. Bottaro  
[cjbottaro@gmail.com](mailto:cjbottaro@gmail.com)wrote:

> I'm trying to understand this correctly. If I have two separate document  
> types (my\_type\_1 and my\_type\_2), and they both have a field (my\_field)  
> which is defined different (string not analyzed and long), I can't do a  
> search on my\_type\_1 sorting by my\_field if there are any documents in the  
> index of my\_type\_2 that have multiple values in my\_field?
> 
> Because of this, I have to prefix all my fields with the document type...  
> which seems wrong. Am I missing something?
> 
> Thanks for the help.
> 
> References:
> 
> "Can't sort on string types with more than one value per doc, or more than  
> one token per field"
> 
> [http://elasticsearch-users.115913.n3.nabble.com/not-analyzed-attribute-gt-Can-t-sort-on-string-types-with-more-than-one-value-per-doc-or-more-than-od-td3848413.html](http://elasticsearch-users.115913.n3.nabble.com/not-analyzed-attribute-gt-Can-t-sort-on-string-types-with-more-than-one-value-per-doc-or-more-than-od-td3848413.html)
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:37am UTC](https://discuss.elastic.co/t/different-document-types-with-shared-field-names/11865/3 "2017-07-06T02:37:23Z")

</div>


