# Name conflicts between types and fields

**URL:** <https://discuss.elastic.co/t/name-conflicts-between-types-and-fields/19407>\
**Category:** Elasticsearch\
**Created:** [August 22, 2014, 11:07am UTC](https://discuss.elastic.co/t/name-conflicts-between-types-and-fields/19407 "2014-08-22T11:07:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karol\_Gwaj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karol_gwaj/32/1324_2.png) [@Karol\_Gwaj](https://discuss.elastic.co/u/Karol_Gwaj)\
**Post date:** [August 22, 2014, 11:07am UTC](https://discuss.elastic.co/t/name-conflicts-between-types-and-fields/19407/1 "2014-08-22T11:07:04Z")

</div>

hi,

is there any way to indicate that field name path used in the query  
represents absolute path ?  
looks like elasticsearch is recognizing that field path starts with type  
name and removes it before executing query

consider example below:

1. insert two test documents:

POST test/sublocality/1  
{  
"name" : "xxx",  
"country" :  
{  
"name" : "yyy"  
}  
}

POST test/_country_/1  
{  
"name" : "zzz",  
"country" :  
{  
"name" : "yyy"  
}  
}

1. execute facet query:

POST test/\_search  
{  
"facets": {  
"term": {  
"terms": {  
"field": "_country.name_",  
"size": 10  
}  
}  
}  
}

i will expect that facet response will contain only one term 'yyy' with  
count 2  
instead im getting 'xxx' with count 1 and 'zzz' with count 1

so looks like elasticsearch recognized that field name is prefixed with  
type (country) and trimmed it:

POST test/\_search  
{  
"facets": {  
"term": {  
"terms": {  
"field": "_name_",  
"size": 10  
}  
}  
}  
}

any idea how to get around it without renaming types and fields ?  
im using _elasticsearch 2.x_

Thx,

--  
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/53b99101-bf16-4905-98c5-49af2217e579%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/53b99101-bf16-4905-98c5-49af2217e579%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![vineeth\_mohan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineeth_mohan_2/32/747_2.png) [@vineeth\_mohan\_2](https://discuss.elastic.co/u/vineeth_mohan_2)\
**Post date:** [August 22, 2014, 6:15pm UTC](https://discuss.elastic.co/t/name-conflicts-between-types-and-fields/19407/2 "2014-08-22T18:15:57Z")

</div>

Hello Karol ,

This is definitely a bug.

I think i understand what happens.  
There is no type support in lucene and ES would be storing all fields as

TYPE.field.full.path format

Which means , there would be country.name and country.country.name field in  
the index.  
If you try with the following query -

{  
"facets": {  
"term": {  
"terms": {  
"field": "country.country.name",  
"size": 10  
}  
}  
}  
}  
You will get the expected result.

I have filed a ISSUE -

> <https://github.com/elastic/elasticsearch/issues/7411>
>
> Steps to reproduce
> 
> \`\`\`
> 
> curl -XPOST 'http://localhost:9200/test/sublocality/1' …-d '{
> "name" : "xxx",
> "country" : 
> {
> "name" : "yyy"
> }
> }'
> curl -XPOST 'http://localhost:9200/test/country/1' -d '{
> "name" : "zzz",
> "country" : 
> {
> "name" : "yyy"
> }
> }'
> 
> curl -XPOST 'http://localhost:9200/test/\_search' -d '{
> "query": {
> "match\_all": {}
> },
> "facets": {
> "term": {
> "terms": {
> "field": "country.name",
> "size": 10
> }
> }
> }
> }'
> {"took":3,"timed\_out":false,"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":2,"max\_score":1.0,"hits":\[{"\_index":"test","\_type":"sublocality","\_id":"1","\_score":1.0,"\_source":{
> "name" : "xxx",
> "country" : 
> {
> "name" : "yyy"
> }
> }},{"\_index":"test","\_type":"country","\_id":"1","\_score":1.0,"\_source":{
> "name" : "zzz",
> "country" : 
> {
> "name" : "yyy"
> }
> }}\]},"facets":{"term":{"\_type":"terms","missing":0,"total":2,"other":0,"terms":\[{"term":"zzz","count":1},{"term":"xxx","count":1}\]}}}
> 
> \`\`\`
> 
> This gives 1 ZZZ and 1 XXX instead of 2 YYY.
> 
> But then 
> 
> \`\`\`
> 
> {
> "query": {
> "match\_all": {}
> },
> "facets": {
> "term": {
> "terms": {
> "field": "country.country.name",
> "size": 10
> }
> }
> }
> }
> \`\`\`
> 
> Gives the expected result.

Thanks  
Vineeth

On Fri, Aug 22, 2014 at 4:37 PM, Karol Gwaj [karol@gwaj.me](mailto:karol@gwaj.me) wrote:

> hi,
> 
> is there any way to indicate that field name path used in the query  
> represents absolute path ?  
> looks like elasticsearch is recognizing that field path starts with type  
> name and removes it before executing query
> 
> consider example below:
> 
> 1. insert two test documents:
> 
> POST test/sublocality/1  
> {  
> "name" : "xxx",  
> "country" :  
> {  
> "name" : "yyy"  
> }  
> }
> 
> POST test/_country_/1  
> {  
> "name" : "zzz",  
> "country" :  
> {  
> "name" : "yyy"  
> }  
> }
> 
> 1. execute facet query:
> 
> POST test/\_search  
> {  
> "facets": {  
> "term": {  
> "terms": {  
> "field": "_country.name [http://country.name](http://country.name)_",  
> "size": 10  
> }  
> }  
> }  
> }
> 
> i will expect that facet response will contain only one term 'yyy' with  
> count 2  
> instead im getting 'xxx' with count 1 and 'zzz' with count 1
> 
> so looks like elasticsearch recognized that field name is prefixed with  
> type (country) and trimmed it:
> 
> POST test/\_search  
> {  
> "facets": {  
> "term": {  
> "terms": {  
> "field": "_name_",  
> "size": 10  
> }  
> }  
> }  
> }
> 
> any idea how to get around it without renaming types and fields ?  
> im using _elasticsearch 2.x_
> 
> Thx,
> 
> --  
> 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/53b99101-bf16-4905-98c5-49af2217e579%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/53b99101-bf16-4905-98c5-49af2217e579%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/53b99101-bf16-4905-98c5-49af2217e579%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/53b99101-bf16-4905-98c5-49af2217e579%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAGdPd5mRzRrwhA6e%2BTgf%3DRck2dHA-VSSsxr1dnorG%3D6EUkiBXw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGdPd5mRzRrwhA6e%2BTgf%3DRck2dHA-VSSsxr1dnorG%3D6EUkiBXw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:06am UTC](https://discuss.elastic.co/t/name-conflicts-between-types-and-fields/19407/3 "2017-07-06T01:06:57Z")

</div>


