# Inconsistent results when searching within one type vs all types

**URL:** https://discuss.elastic.co/t/inconsistent-results-when-searching-within-one-type-vs-all-types/14563
**Category:** Elasticsearch
**Created:** [November 24, 2013, 10:41am UTC](https://discuss.elastic.co/t/inconsistent-results-when-searching-within-one-type-vs-all-types/14563 "2013-11-24T10:41:27Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Amit\_Soni](https://avatars.discourse-cdn.com/v4/letter/a/c0e974/32.png) [@Amit\_Soni](https://discuss.elastic.co/u/Amit_Soni)
#### Post date: [November 24, 2013, 10:41am UTC](https://discuss.elastic.co/t/inconsistent-results-when-searching-within-one-type-vs-all-types/14563/1 "2013-11-24T10:41:27Z")

</div>

Hi all - I just observed something weird and was wondering if anyone else  
has seen this type of behavior and what might be the possible reason for  
the same.

We are using 3 types within a single index. When I execute my  
filtered-query against a specific type, I get a few matches. However when I  
run the same query but specify all the types, I do not get any documents.

For instance:

Query against http://[host]:9201/index\_alias1/_type1_ ---\> Gives me a few  
matches

Query against http://[host]:9201/index\_alias1/_type1_, type2, type3 ---\>  
Gives me zero matches

Note that these three types have different mappings altogether.

Very curious to know what might be causing this inconsistent behavior.

-Amit.

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)
#### Post date: [November 25, 2013, 6:53am UTC](https://discuss.elastic.co/t/inconsistent-results-when-searching-within-one-type-vs-all-types/14563/2 "2013-11-25T06:53:37Z")

</div>

Do the different mappings contain fields with similar names, but different  
types (string, int, long, etc.)? If so, are there any errors in the log?  
Since the types all share a same Lucene index, the fields with similar  
names must be of the same field type even if they are in different  
elasticsearch types.

Cheers,

Ivan

On Sun, Nov 24, 2013 at 2:41 AM, Amit Soni [amitsoni29@gmail.com](mailto:amitsoni29@gmail.com) wrote:

> Hi all - I just observed something weird and was wondering if anyone else  
> has seen this type of behavior and what might be the possible reason for  
> the same.
> 
> We are using 3 types within a single index. When I execute my  
> filtered-query against a specific type, I get a few matches. However when I  
> run the same query but specify all the types, I do not get any documents.
> 
> For instance:
> 
> Query against http://[host]:9201/index\_alias1/_type1_ ---\> Gives me a few  
> matches
> 
> Query against http://[host]:9201/index\_alias1/_type1_, type2, type3 ---\>  
> Gives me zero matches
> 
> Note that these three types have different mappings altogether.
> 
> Very curious to know what might be causing this inconsistent behavior.
> 
> -Amit.
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Amit\_Soni](https://avatars.discourse-cdn.com/v4/letter/a/c0e974/32.png) [@Amit\_Soni](https://discuss.elastic.co/u/Amit_Soni)
#### Post date: [November 25, 2013, 5:46pm UTC](https://discuss.elastic.co/t/inconsistent-results-when-searching-within-one-type-vs-all-types/14563/3 "2013-11-25T17:46:46Z")

</div>

Hi Ivan - Thanks for your response. There are no errors in the logs.  
However I do have three fields of the same name and same type (string)  
across two different elasticsearch types.  
So as a best design practice, is it recommended that the field names should  
be different within an index even if they are spread across different  
elasticsearch types?

-Amit.

On Sun, Nov 24, 2013 at 10:53 PM, Ivan Brusic [ivan@brusic.com](mailto:ivan@brusic.com) wrote:

> Do the different mappings contain fields with similar names, but different  
> types (string, int, long, etc.)? If so, are there any errors in the log?  
> Since the types all share a same Lucene index, the fields with similar  
> names must be of the same field type even if they are in different  
> elasticsearch types.
> 
> Cheers,
> 
> Ivan
> 
> On Sun, Nov 24, 2013 at 2:41 AM, Amit Soni [amitsoni29@gmail.com](mailto:amitsoni29@gmail.com) wrote:
> 
> > Hi all - I just observed something weird and was wondering if anyone else  
> > has seen this type of behavior and what might be the possible reason for  
> > the same.
> > 
> > We are using 3 types within a single index. When I execute my  
> > filtered-query against a specific type, I get a few matches. However when I  
> > run the same query but specify all the types, I do not get any documents.
> > 
> > For instance:
> > 
> > Query against http://[host]:9201/index\_alias1/_type1_ ---\> Gives me a  
> > few matches
> > 
> > Query against http://[host]:9201/index\_alias1/_type1_, type2, type3 ---\>  
> > Gives me zero matches
> > 
> > Note that these three types have different mappings altogether.
> > 
> > Very curious to know what might be causing this inconsistent behavior.
> > 
> > -Amit.
> > 
> > --  
> > 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).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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: [November 26, 2013, 12:33pm UTC](https://discuss.elastic.co/t/inconsistent-results-when-searching-within-one-type-vs-all-types/14563/4 "2013-11-26T12:33:50Z")

</div>

Hey,

would be great if you could create a reproducible example using curl and  
gist, so we can check what is wrong with the query, the data, the  
configuration or elasticsearch 🙂

Thanks!

--Alex

On Mon, Nov 25, 2013 at 6:46 PM, Amit Soni [amitsoni29@gmail.com](mailto:amitsoni29@gmail.com) wrote:

> Hi Ivan - Thanks for your response. There are no errors in the logs.  
> However I do have three fields of the same name and same type (string)  
> across two different elasticsearch types.  
> So as a best design practice, is it recommended that the field names  
> should be different within an index even if they are spread across  
> different elasticsearch types?
> 
> -Amit.
> 
> On Sun, Nov 24, 2013 at 10:53 PM, Ivan Brusic [ivan@brusic.com](mailto:ivan@brusic.com) wrote:
> 
> > Do the different mappings contain fields with similar names, but  
> > different types (string, int, long, etc.)? If so, are there any errors in  
> > the log? Since the types all share a same Lucene index, the fields with  
> > similar names must be of the same field type even if they are in different  
> > elasticsearch types.
> > 
> > Cheers,
> > 
> > Ivan
> > 
> > On Sun, Nov 24, 2013 at 2:41 AM, Amit Soni [amitsoni29@gmail.com](mailto:amitsoni29@gmail.com) wrote:
> > 
> > > Hi all - I just observed something weird and was wondering if anyone  
> > > else has seen this type of behavior and what might be the possible reason  
> > > for the same.
> > > 
> > > We are using 3 types within a single index. When I execute my  
> > > filtered-query against a specific type, I get a few matches. However when I  
> > > run the same query but specify all the types, I do not get any documents.
> > > 
> > > For instance:
> > > 
> > > Query against http://[host]:9201/index\_alias1/_type1_ ---\> Gives me a  
> > > few matches
> > > 
> > > Query against http://[host]:9201/index\_alias1/_type1_, type2, type3  
> > > ---\> Gives me zero matches
> > > 
> > > Note that these three types have different mappings altogether.
> > > 
> > > Very curious to know what might be causing this inconsistent behavior.
> > > 
> > > -Amit.
> > > 
> > > --  
> > > 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).  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > 
> > --  
> > 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).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![Amit\_Soni](https://avatars.discourse-cdn.com/v4/letter/a/c0e974/32.png) [@Amit\_Soni](https://discuss.elastic.co/u/Amit_Soni)
#### Post date: [November 26, 2013, 5:35pm UTC](https://discuss.elastic.co/t/inconsistent-results-when-searching-within-one-type-vs-all-types/14563/5 "2013-11-26T17:35:54Z")

</div>

Hi Alex - Let me give it a try. Since the index is big, I will need to take  
out the portion of data which might be causing a problem in order to  
prepare a standalone example. Let me try for that and come back.

-Amit.

On Tue, Nov 26, 2013 at 4:33 AM, Alexander Reelsen [alr@spinscale.de](mailto:alr@spinscale.de) wrote:

> Hey,
> 
> would be great if you could create a reproducible example using curl and  
> gist, so we can check what is wrong with the query, the data, the  
> configuration or elasticsearch 🙂
> 
> Thanks!
> 
> --Alex
> 
> On Mon, Nov 25, 2013 at 6:46 PM, Amit Soni [amitsoni29@gmail.com](mailto:amitsoni29@gmail.com) wrote:
> 
> > Hi Ivan - Thanks for your response. There are no errors in the logs.  
> > However I do have three fields of the same name and same type (string)  
> > across two different elasticsearch types.  
> > So as a best design practice, is it recommended that the field names  
> > should be different within an index even if they are spread across  
> > different elasticsearch types?
> > 
> > -Amit.
> > 
> > On Sun, Nov 24, 2013 at 10:53 PM, Ivan Brusic [ivan@brusic.com](mailto:ivan@brusic.com) wrote:
> > 
> > > Do the different mappings contain fields with similar names, but  
> > > different types (string, int, long, etc.)? If so, are there any errors in  
> > > the log? Since the types all share a same Lucene index, the fields with  
> > > similar names must be of the same field type even if they are in different  
> > > elasticsearch types.
> > > 
> > > Cheers,
> > > 
> > > Ivan
> > > 
> > > On Sun, Nov 24, 2013 at 2:41 AM, Amit Soni [amitsoni29@gmail.com](mailto:amitsoni29@gmail.com) wrote:
> > > 
> > > > Hi all - I just observed something weird and was wondering if anyone  
> > > > else has seen this type of behavior and what might be the possible reason  
> > > > for the same.
> > > > 
> > > > We are using 3 types within a single index. When I execute my  
> > > > filtered-query against a specific type, I get a few matches. However when I  
> > > > run the same query but specify all the types, I do not get any documents.
> > > > 
> > > > For instance:
> > > > 
> > > > Query against http://[host]:9201/index\_alias1/_type1_ ---\> Gives me a  
> > > > few matches
> > > > 
> > > > Query against http://[host]:9201/index\_alias1/_type1_, type2, type3  
> > > > ---\> Gives me zero matches
> > > > 
> > > > Note that these three types have different mappings altogether.
> > > > 
> > > > Very curious to know what might be causing this inconsistent behavior.
> > > > 
> > > > -Amit.
> > > > 
> > > > --  
> > > > 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).  
> > > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > > 
> > > --  
> > > 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).  
> > > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> > 
> > --  
> > 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).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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/CAAOGaQJ7wr5X1DjYVNNe2Pd2B2cWur4pXCDA59ur-9fBBUQ%2BbA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAOGaQJ7wr5X1DjYVNNe2Pd2B2cWur4pXCDA59ur-9fBBUQ%2BbA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:04am UTC](https://discuss.elastic.co/t/inconsistent-results-when-searching-within-one-type-vs-all-types/14563/6 "2017-07-06T02:04:46Z")

</div>


