# Fielddata and different types with the same field name in index

**URL:** <https://discuss.elastic.co/t/fielddata-and-different-types-with-the-same-field-name-in-index/28482>\
**Category:** Elasticsearch\
**Created:** [September 2, 2015, 4:01am UTC](https://discuss.elastic.co/t/fielddata-and-different-types-with-the-same-field-name-in-index/28482 "2015-09-02T04:01:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anton\_Bogdanovich](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anton_bogdanovich/32/44922_2.png) [@Anton\_Bogdanovich](https://discuss.elastic.co/u/Anton_Bogdanovich)\
**Post date:** [September 2, 2015, 4:01am UTC](https://discuss.elastic.co/t/fielddata-and-different-types-with-the-same-field-name-in-index/28482/1 "2015-09-02T04:01:42Z")

</div>

I have two types (type\_a and type\_b) in one index and both types have contact\_id (long) field.  
When I use fielddata stats api (/\_cat/fielddata?v&fields=contact\_id&pretty), it has only one field named contact\_id.  
Does this mean that both fields from different types have the same fielddata field?

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [September 2, 2015, 7:58am UTC](https://discuss.elastic.co/t/fielddata-and-different-types-with-the-same-field-name-in-index/28482/2 "2015-09-02T07:58:08Z")

</div>

Yes, different types will share the same underlying field in the index and in field data for fields with the same name. In 2.0 we have implemented stricter mapping rules so that using the same field name across multiple types is less trappy. For more information on those changes take a look at: [https://www.elastic.co/blog/great-mapping-refactoring#conflicting-mappings](https://www.elastic.co/blog/great-mapping-refactoring#conflicting-mappings)

---

<div class="post-metadata">

**Author:** ![Anton\_Bogdanovich](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anton_bogdanovich/32/44922_2.png) [@Anton\_Bogdanovich](https://discuss.elastic.co/u/Anton_Bogdanovich)\
**Post date:** [September 2, 2015, 6:39pm UTC](https://discuss.elastic.co/t/fielddata-and-different-types-with-the-same-field-name-in-index/28482/3 "2015-09-02T18:39:00Z")

</div>

Thanks for reply.

We have an issue with not working aggregations  
([Aggregations stop working silently on elasticsearch 1.4.4](https://discuss.elastic.co/t/aggregations-stop-working-silently-on-elasticsearch-1-4-4/28480))  
Could this mapping be an issue (child type field has doc\_values: true and parent type does not) ?

```
           contact: {
              properties: {
                contact_id: { type: 'long', index: 'not_analyzed'}
              }
            },
            event: {
              _parent: { type: :contact },
              properties: {
                user_id: { type: 'long', index: 'not_analyzed' },
                contact_id: { type: 'long', index: 'not_analyzed', doc_values: true },
                data: { type: 'object', index: 'not_analyzed' },
              }
            }

```

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [September 3, 2015, 7:52am UTC](https://discuss.elastic.co/t/fielddata-and-different-types-with-the-same-field-name-in-index/28482/4 "2015-09-03T07:52:33Z")

</div>

Lets keep the conversation about that issue on that topic to avoid a split conversation in multiple places.

---

<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 5, 2017, 11:52pm UTC](https://discuss.elastic.co/t/fielddata-and-different-types-with-the-same-field-name-in-index/28482/5 "2017-07-05T23:52:22Z")

</div>


