# Searching Multiple types within an Index not providing results as expected

**URL:** https://discuss.elastic.co/t/searching-multiple-types-within-an-index-not-providing-results-as-expected/16845
**Category:** Elasticsearch
**Created:** [April 7, 2014, 1:43pm UTC](https://discuss.elastic.co/t/searching-multiple-types-within-an-index-not-providing-results-as-expected/16845 "2014-04-07T13:43:24Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Ramdev\_Wudali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ramdev_wudali/32/7894_2.png) [@Ramdev\_Wudali](https://discuss.elastic.co/u/Ramdev_Wudali)
#### Post date: [April 7, 2014, 1:43pm UTC](https://discuss.elastic.co/t/searching-multiple-types-within-an-index-not-providing-results-as-expected/16845/1 "2014-04-07T13:43:24Z")

</div>

Hi :  
I have two types ("type1", and "type2") within my index "index1". When I  
perform a search

I index two documents with the same id (the mappings are different but the  
two types are "linked" via an "id" field) in each of the types. The "id"  
field has the same value in the two types.

curl -XPOST "[http://localhost:9200/index1/type1,type2/\_search](http://localhost:9200/index1/type1,type2/_search)" -d'  
{  
"query" :  
{  
"term": {  
"id": {  
"value": "10100"  
}  
}  
}  
}'

I expect two hits (1 from "type1" and another from "type2"). However, I  
only get the document from "type1" (which was incidentally indexed first).  
However, If I perform these two queries separately :

curl -XPOST "[http://localhost:9200/index1/type1/\_search](http://localhost:9200/index1/type1/_search)" -d'  
{  
"query" :  
{  
"term": {  
"id": {  
"value": "10100"  
}  
}  
}  
}'

AND

curl -XPOST "[http://localhost:9200/index1/type2/\_search](http://localhost:9200/index1/type2/_search)" -d'  
{  
"query" :  
{  
"term": {  
"id": {  
"value": "10100"  
}  
}  
}  
}'

I retrieve two hits (one from each type).

What might be happening that is causing only one document to be returned  
when I search across the two types.

Thanks

Ramdev

--  
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/2ea05272-8a79-4319-b546-fa73b0183e90%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2ea05272-8a79-4319-b546-fa73b0183e90%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![brian\_yoder](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@brian\_yoder](https://discuss.elastic.co/u/brian_yoder)
#### Post date: [April 8, 2014, 8:58pm UTC](https://discuss.elastic.co/t/searching-multiple-types-within-an-index-not-providing-results-as-expected/16845/2 "2014-04-08T20:58:38Z")

</div>

When you query each type separately, ES is automatically choosing the  
correct analyzer for your query term.

But when you query both types, ES can only choose one analyzer, and if the  
two types are mapped with analyzers that are different enough, that one  
analyzer will work in the type to which it belongs but not to the other  
type.

A good way to let us check this would be to create a gist with the full set  
of settings and mappings for your index.

Brian

--  
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/f07b5ad2-e851-458d-adcb-ddb9abefd26c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f07b5ad2-e851-458d-adcb-ddb9abefd26c%40googlegroups.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:37am UTC](https://discuss.elastic.co/t/searching-multiple-types-within-an-index-not-providing-results-as-expected/16845/3 "2017-07-06T01:37:30Z")

</div>


