# Inconsistent query results in ES

**URL:** <https://discuss.elastic.co/t/inconsistent-query-results-in-es/7136>\
**Category:** Elasticsearch\
**Created:** [March 26, 2012, 11:18pm UTC](https://discuss.elastic.co/t/inconsistent-query-results-in-es/7136 "2012-03-26T23:18:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anurag\_Phadke](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@Anurag\_Phadke](https://discuss.elastic.co/u/Anurag_Phadke)\
**Post date:** [March 26, 2012, 11:18pm UTC](https://discuss.elastic.co/t/inconsistent-query-results-in-es/7136/1 "2012-03-26T23:18:24Z")

</div>

Hello,  
ES is sometimes failing to return results for a query that should in  
fact return some.  
For example:  
http://:9200/logs/builds/\_search?q=starttime:1330704266  
This sometimes returns no results, and sometimes returns 1 (1 being  
correct). If I further shorten the query to omit the doc\_type:

http://:9200/logs/\_search?q=starttime:1330704266  
I always get 0 hits, even though I should get 3.  
Strangely, this only seems to occur with this specific field  
(starttime), which holds an integer, not a string. If I query the  
same documents using another (string) field, the query always  
succeeds:

http://:9200/logs/builds/\_search?q=testgroup\_id:1330704266-f80af377a148f1205f4f6ed9441244501b3c46a0  
Why is ES failing to (sometimes) return the correct results for the  
integer field?

I should note that the mapping  
(http://:9200/logs/builds/\_mapping) indicates starttime as  
a string; is this the source of the problem? Even so, I don't  
understand the inconsistency in the returned hits.

Any idea what might be happening here?

-anurag

--  
Blog: [http://anurag.co](http://anurag.co)  
Twitter: @anuragphadke ([https://twitter.com/#!/anuragphadke](https://twitter.com/#!/anuragphadke))

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 28, 2012, 10:22am UTC](https://discuss.elastic.co/t/inconsistent-query-results-in-es/7136/2 "2012-03-28T10:22:56Z")

</div>

Is there a chance that you have starttime under several types in the same  
index (builds), once as string and once as numeric? You can check that  
using the get mapping API on the whole index. Also, which elasticsearch  
version are you using?

On Tue, Mar 27, 2012 at 1:18 AM, Anurag [anurag.phadke@gmail.com](mailto:anurag.phadke@gmail.com) wrote:

> Hello,  
> ES is sometimes failing to return results for a query that should in  
> fact return some.  
> For example:  
> http://:9200/logs/builds/\_search?q=starttime:1330704266  
> This sometimes returns no results, and sometimes returns 1 (1 being  
> correct). If I further shorten the query to omit the doc\_type:
> 
> http://:9200/logs/\_search?q=starttime:1330704266  
> I always get 0 hits, even though I should get 3.  
> Strangely, this only seems to occur with this specific field  
> (starttime), which holds an integer, not a string. If I query the  
> same documents using another (string) field, the query always  
> succeeds:
> 
> http://  
> :9200/logs/builds/\_search?q=testgroup\_id:1330704266-f80af377a148f1205f4f6ed9441244501b3c46a0  
> Why is ES failing to (sometimes) return the correct results for the  
> integer field?
> 
> I should note that the mapping  
> (http://:9200/logs/builds/\_mapping) indicates starttime as  
> a string; is this the source of the problem? Even so, I don't  
> understand the inconsistency in the returned hits.
> 
> Any idea what might be happening here?
> 
> -anurag
> 
> --  
> Blog: [http://anurag.co](http://anurag.co)  
> Twitter: @anuragphadke ([https://twitter.com/#!/anuragphadke](https://twitter.com/#!/anuragphadke))

---

<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, 3:34am UTC](https://discuss.elastic.co/t/inconsistent-query-results-in-es/7136/3 "2017-07-06T03:34:25Z")

</div>


