# Strange behavior: results count depend on arguments count

**URL:** https://discuss.elastic.co/t/strange-behavior-results-count-depend-on-arguments-count/18179
**Category:** Elasticsearch
**Created:** [June 18, 2014, 12:01pm UTC](https://discuss.elastic.co/t/strange-behavior-results-count-depend-on-arguments-count/18179 "2014-06-18T12:01:32Z")
**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, 12:01pm UTC](https://discuss.elastic.co/t/strange-behavior-results-count-depend-on-arguments-count/18179/1 "2014-06-18T12:01:32Z")

</div>

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"}'

According to example above we have test index with 2 documents (both with  
"apple" id) in different types.  
When we make curl -XGET [http://192.168.0.118:9200/test/\_mget?pretty](http://192.168.0.118:9200/test/_mget?pretty) -d  
'{ids:["apple","apple"]}'  
We see this:  
{  
"docs" : [ {  
"\_index" : "test",  
"\_type" : "fruit",  
"\_id" : "apple",  
"\_version" : 1,  
"found" : true, "\_source" : {data:"Just red apple"}  
}, {  
"\_index" : "test",  
"\_type" : "fruit",  
"\_id" : "apple",  
"\_version" : 1,  
"found" : true, "\_source" : {data:"Just red apple"}  
} ]  
}

As you can see documents are duplicated.  
So if we request curl -XGET [http://192.168.0.118:9200/test/\_mget?pretty](http://192.168.0.118:9200/test/_mget?pretty) -d  
'{ids:["apple","apple","apple"]}' we will see 3 documents in result set and  
so on.

I think the right way to resolve this issue is to ignore duplicate  
identificators in "ids" parameter.

--  
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/eb04cff0-e28a-453c-8ead-a7824a6e3073%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/eb04cff0-e28a-453c-8ead-a7824a6e3073%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [June 18, 2014, 1:12pm UTC](https://discuss.elastic.co/t/strange-behavior-results-count-depend-on-arguments-count/18179/2 "2014-06-18T13:12:55Z")

</div>

So, what is happening here.

1st request:  
You set index to test  
type is not set  
id is apple  
It "guess" the type and send you the document from fruit type.

2nd request:  
It's exactly the same request as the first one. So it gives you the same response.

To have the correct results, you should ask for:

GET /test/\_mget?pretty  
{  
"docs" : [  
{  
"\_type" : "company",  
"\_id" : "apple"  
},  
{  
"\_type" : "fruit",  
"\_id" : "apple"  
}  
]  
}

Or you should use unique ids for the whole index.

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 18 juin 2014 à 14:01:36, Hovsep Avakyan ([avakyanhovsep@gmail.com](mailto:avakyanhovsep@gmail.com)) a écrit:

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"}'

According to example above we have test index with 2 documents (both with "apple" id) in different types.  
When we make curl -XGET [http://192.168.0.118:9200/test/\_mget?pretty](http://192.168.0.118:9200/test/_mget?pretty) -d '{ids:["apple","apple"]}'  
We see this:  
{  
"docs" : [ {  
"\_index" : "test",  
"\_type" : "fruit",  
"\_id" : "apple",  
"\_version" : 1,  
"found" : true, "\_source" : {data:"Just red apple"}  
}, {  
"\_index" : "test",  
"\_type" : "fruit",  
"\_id" : "apple",  
"\_version" : 1,  
"found" : true, "\_source" : {data:"Just red apple"}  
} ]  
}

As you can see documents are duplicated.  
So if we request curl -XGET [http://192.168.0.118:9200/test/\_mget?pretty](http://192.168.0.118:9200/test/_mget?pretty) -d '{ids:["apple","apple","apple"]}' we will see 3 documents in result set and so on.

## I think the right way to resolve this issue is to ignore duplicate identificators in "ids" parameter.

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/eb04cff0-e28a-453c-8ead-a7824a6e3073%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/eb04cff0-e28a-453c-8ead-a7824a6e3073%40googlegroups.com).  
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/etPan.53a19057.41b71efb.5d8%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.53a19057.41b71efb.5d8%40MacBook-Air-de-David.local).  
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-results-count-depend-on-arguments-count/18179/3 "2017-07-06T01:21:33Z")

</div>


