# Strange behavior: same id in different types

**URL:** https://discuss.elastic.co/t/strange-behavior-same-id-in-different-types/18178
**Category:** Elasticsearch
**Created:** [June 18, 2014, 11:57am UTC](https://discuss.elastic.co/t/strange-behavior-same-id-in-different-types/18178 "2014-06-18T11:57:47Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Hovsep\_Avakyan](https://avatars.discourse-cdn.com/v4/letter/h/ed8c4c/32.png) [@Hovsep\_Avakyan](https://discuss.elastic.co/u/Hovsep_Avakyan)
#### Post date: [June 18, 2014, 11:57am UTC](https://discuss.elastic.co/t/strange-behavior-same-id-in-different-types/18178/1 "2014-06-18T11:57:47Z")

</div>

Hi ! I just started play with ES and noted some strange behavior:

First I just indexed 2 documents:  
curl -XPUT [http://192.168.0.118:9200/test/company/apple](http://192.168.0.118:9200/test/company/apple) -d '{data:"Apple  
corp"}'  
curl -XPUT [http://192.168.0.118:9200/test/fruit/apple](http://192.168.0.118:9200/test/fruit/apple) -d '{data:"Just red  
apple"}'

As you can see, they have same id and placed in same index,but different  
types.  
Ok, next I perform multi get request:

curl -XGET [http://192.168.0.118:9200/test/\_mget?pretty](http://192.168.0.118:9200/test/_mget?pretty) -d '{ids:["apple"]}'

Response:

{  
"docs" : [ {  
"\_index" : "test",  
"\_type" : "fruit",  
"\_id" : "apple",  
"\_version" : 1,  
"found" : true, "\_source" : {data:"Just red apple"}  
} ]  
}

As you can see only one document returned. Why not both? I find such  
behavior very ambiguous. I think if we request whole index, so all  
documents with given id should be returned regardless of type.

--  
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/600e6174-036c-48dc-8c6d-2c31e9c9eccb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/600e6174-036c-48dc-8c6d-2c31e9c9eccb%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [June 19, 2014, 9:21am UTC](https://discuss.elastic.co/t/strange-behavior-same-id-in-different-types/18178/2 "2014-06-19T09:21:32Z")

</div>

Hey,

your request is already ambigous. You specify a single ID, but expect two  
results to return, as you did not specify a type. However to identify a  
document in a unique fashion, you need the tuple of index/type/id, of which  
a type is missing here.

So, either specify all three, or maybe elasticsearch should possibly reject  
such a request and return an error message. Maybe create a github issue?

--Alex

On Wed, Jun 18, 2014 at 1:57 PM, Hovsep Avakyan [avakyanhovsep@gmail.com](mailto:avakyanhovsep@gmail.com)  
wrote:

> Hi ! I just started play with ES and noted some strange behavior:
> 
> First I just indexed 2 documents:  
> curl -XPUT [http://192.168.0.118:9200/test/company/apple](http://192.168.0.118:9200/test/company/apple) -d '{data:"Apple  
> corp"}'  
> curl -XPUT [http://192.168.0.118:9200/test/fruit/apple](http://192.168.0.118:9200/test/fruit/apple) -d '{data:"Just red  
> apple"}'
> 
> As you can see, they have same id and placed in same index,but different  
> types.  
> Ok, next I perform multi get request:
> 
> curl -XGET [http://192.168.0.118:9200/test/\_mget?pretty](http://192.168.0.118:9200/test/_mget?pretty) -d  
> '{ids:["apple"]}'
> 
> Response:
> 
> {  
> "docs" : [ {  
> "\_index" : "test",  
> "\_type" : "fruit",  
> "\_id" : "apple",  
> "\_version" : 1,  
> "found" : true, "\_source" : {data:"Just red apple"}  
> } ]  
> }
> 
> As you can see only one document returned. Why not both? I find such  
> behavior very ambiguous. I think if we request whole index, so all  
> documents with given id should be returned regardless of type.
> 
> --  
> 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/600e6174-036c-48dc-8c6d-2c31e9c9eccb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/600e6174-036c-48dc-8c6d-2c31e9c9eccb%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/600e6174-036c-48dc-8c6d-2c31e9c9eccb%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/600e6174-036c-48dc-8c6d-2c31e9c9eccb%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/CAGCwEM-AMUZveO1KtrTKYCDa4eJENTZ\_3\_0uFmHvd5ABsVd02Q%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM-AMUZveO1KtrTKYCDa4eJENTZ_3_0uFmHvd5ABsVd02Q%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:21am UTC](https://discuss.elastic.co/t/strange-behavior-same-id-in-different-types/18178/3 "2017-07-06T01:21:16Z")

</div>


