# Filtering docs on boolean value

**URL:** <https://discuss.elastic.co/t/filtering-docs-on-boolean-value/5344>\
**Category:** Elasticsearch\
**Created:** [September 11, 2011, 1:55am UTC](https://discuss.elastic.co/t/filtering-docs-on-boolean-value/5344 "2011-09-11T01:55:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kikster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kikster/32/3117_2.png) [@kikster](https://discuss.elastic.co/u/kikster)\
**Post date:** [September 11, 2011, 1:55am UTC](https://discuss.elastic.co/t/filtering-docs-on-boolean-value/5344/1 "2011-09-11T01:55:48Z")

</div>

I've been trying to get these types of queries working for a while,  
but no luck. I'm trying to filter documents based on a boolean value  
(basically only show documents where show == true).

Here's my query:

> <https://gist.github.com/cdolivares/1158523>

Documents are being matched where show == false. Any ideas why this  
would happen even though I explicitly say to filter them out?

---

<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:** [September 11, 2011, 10:49am UTC](https://discuss.elastic.co/t/filtering-docs-on-boolean-value/5344/2 "2011-09-11T10:49:55Z")

</div>

This should work. Can you post a recreation (no need for the custom score  
query you use, just use match\_all). See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help)

On Sun, Sep 11, 2011 at 4:55 AM, Chris  
[christopherdavidolivares@gmail.com](mailto:christopherdavidolivares@gmail.com)wrote:

> I've been trying to get these types of queries working for a while,  
> but no luck. I'm trying to filter documents based on a boolean value  
> (basically only show documents where show == true).
> 
> Here's my query:
> 
> [1158523’s gists · GitHub](https://gist.github.com/1158523)
> 
> Documents are being matched where show == false. Any ideas why this  
> would happen even though I explicitly say to filter them out?

---

<div class="post-metadata">

**Author:** ![kikster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kikster/32/3117_2.png) [@kikster](https://discuss.elastic.co/u/kikster)\
**Post date:** [September 11, 2011, 9:18pm UTC](https://discuss.elastic.co/t/filtering-docs-on-boolean-value/5344/3 "2011-09-11T21:18:21Z")

</div>

I can't seem to reproduce the error with curl recreations. When I run  
the query against my dataset, there are a lot of offending documents.  
However, when I created a new index with the data of a few of the  
offending documents, everything works great. The documents that  
wrongly match the query in my original dataset are correctly filtered  
when I create the new index (even though I only indexed 3 documents to  
test). I'm completely stumped. I have around 600 indexed documents  
(each one around 20kB, and am running elasticsearch on 64Mb of memory,  
far below the recommended standard configuration. Could malformed  
data in a few of my documents cause the query to not match? Could  
running on 64Mb of memory be the issue?

On Sep 11, 3:49 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> This should work. Can you post a recreation (no need for the custom score  
> query you use, just use match\_all). Seehttp://www.elasticsearch.org/help
> 
> On Sun, Sep 11, 2011 at 4:55 AM, Chris  
> [christopherdavidoliva...@gmail.com](mailto:christopherdavidoliva...@gmail.com)wrote:
> 
> > I've been trying to get these types of queries working for a while,  
> > but no luck. I'm trying to filter documents based on a boolean value  
> > (basically only show documents where show == true).
> 
> > Here's my query:
> 
> > [1158523’s gists · GitHub](https://gist.github.com/1158523)
> 
> > Documents are being matched where show == false. Any ideas why this  
> > would happen even though I explicitly say to filter them out?

---

<div class="post-metadata">

**Author:** ![kikster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kikster/32/3117_2.png) [@kikster](https://discuss.elastic.co/u/kikster)\
**Post date:** [September 12, 2011, 2:09am UTC](https://discuss.elastic.co/t/filtering-docs-on-boolean-value/5344/4 "2011-09-12T02:09:37Z")

</div>

Finally able to reproduce the error.

> <https://gist.github.com/cdolivares/1210453>

On Sep 11, 2:18 pm, Chris [christopherdavidoliva...@gmail.com](mailto:christopherdavidoliva...@gmail.com) wrote:

> I can't seem to reproduce the error with curl recreations. When I run  
> the query against my dataset, there are a lot of offending documents.  
> However, when I created a new index with the data of a few of the  
> offending documents, everything works great. The documents that  
> wrongly match the query in my original dataset are correctly filtered  
> when I create the new index (even though I only indexed 3 documents to  
> test). I'm completely stumped. I have around 600 indexed documents  
> (each one around 20kB, and am running elasticsearch on 64Mb of memory,  
> far below the recommended standard configuration. Could malformed  
> data in a few of my documents cause the query to not match? Could  
> running on 64Mb of memory be the issue?
> 
> On Sep 11, 3:49 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > This should work. Can you post a recreation (no need for the custom score  
> > query you use, just use match\_all). Seehttp://www.elasticsearch.org/help
> 
> > On Sun, Sep 11, 2011 at 4:55 AM, Chris  
> > [christopherdavidoliva...@gmail.com](mailto:christopherdavidoliva...@gmail.com)wrote:
> 
> > > I've been trying to get these types of queries working for a while,  
> > > but no luck. I'm trying to filter documents based on a boolean value  
> > > (basically only show documents where show == true).
> 
> > > Here's my query:
> 
> > > [1158523’s gists · GitHub](https://gist.github.com/1158523)
> 
> > > Documents are being matched where show == false. Any ideas why this  
> > > would happen even though I explicitly say to filter them out?

---

<div class="post-metadata">

**Author:** ![kikster](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kikster/32/3117_2.png) [@kikster](https://discuss.elastic.co/u/kikster)\
**Post date:** [September 12, 2011, 2:30am UTC](https://discuss.elastic.co/t/filtering-docs-on-boolean-value/5344/5 "2011-09-12T02:30:07Z")

</div>

One more thing, the filter works properly when I index the data  
without setting "reviews" to type "nested".

On Sep 11, 7:09 pm, Chris [christopherdavidoliva...@gmail.com](mailto:christopherdavidoliva...@gmail.com) wrote:

> Finally able to reproduce the error.
> 
> [gist:1210453 · GitHub](https://gist.github.com/1210453)
> 
> On Sep 11, 2:18 pm, Chris [christopherdavidoliva...@gmail.com](mailto:christopherdavidoliva...@gmail.com) wrote:
> 
> > I can't seem to reproduce the error with curl recreations. When I run  
> > the query against my dataset, there are a lot of offending documents.  
> > However, when I created a new index with the data of a few of the  
> > offending documents, everything works great. The documents that  
> > wrongly match the query in my original dataset are correctly filtered  
> > when I create the new index (even though I only indexed 3 documents to  
> > test). I'm completely stumped. I have around 600 indexed documents  
> > (each one around 20kB, and am running elasticsearch on 64Mb of memory,  
> > far below the recommended standard configuration. Could malformed  
> > data in a few of my documents cause the query to not match? Could  
> > running on 64Mb of memory be the issue?
> 
> > On Sep 11, 3:49 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > > This should work. Can you post a recreation (no need for the custom score  
> > > query you use, just use match\_all). Seehttp://www.elasticsearch.org/help
> 
> > > On Sun, Sep 11, 2011 at 4:55 AM, Chris  
> > > [christopherdavidoliva...@gmail.com](mailto:christopherdavidoliva...@gmail.com)wrote:
> 
> > > > I've been trying to get these types of queries working for a while,  
> > > > but no luck. I'm trying to filter documents based on a boolean value  
> > > > (basically only show documents where show == true).
> 
> > > > Here's my query:
> 
> > > > [1158523’s gists · GitHub](https://gist.github.com/1158523)
> 
> > > > Documents are being matched where show == false. Any ideas why this  
> > > > would happen even though I explicitly say to filter them out?

---

<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:** [September 12, 2011, 8:26am UTC](https://discuss.elastic.co/t/filtering-docs-on-boolean-value/5344/6 "2011-09-12T08:26:27Z")

</div>

Hi,

Thanks for the recreation!. Found the problem (a tricky one to track...),  
opened an issue: [Nested Mapping: Nested object with a null value causes wrong indexing structure (resulting in wrong search responses) · Issue #1323 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1323).  
Fixed in 0.17 branch and master. 0.17.7 will be released in a day or two,  
once Lucene 3.4.0 is out.

-shay.banon

On Mon, Sep 12, 2011 at 5:30 AM, Chris  
[christopherdavidolivares@gmail.com](mailto:christopherdavidolivares@gmail.com)wrote:

> One more thing, the filter works properly when I index the data  
> without setting "reviews" to type "nested".
> 
> On Sep 11, 7:09 pm, Chris [christopherdavidoliva...@gmail.com](mailto:christopherdavidoliva...@gmail.com) wrote:
> 
> > Finally able to reproduce the error.
> > 
> > [gist:1210453 · GitHub](https://gist.github.com/1210453)
> > 
> > On Sep 11, 2:18 pm, Chris [christopherdavidoliva...@gmail.com](mailto:christopherdavidoliva...@gmail.com) wrote:
> > 
> > > I can't seem to reproduce the error with curl recreations. When I run  
> > > the query against my dataset, there are a lot of offending documents.  
> > > However, when I created a new index with the data of a few of the  
> > > offending documents, everything works great. The documents that  
> > > wrongly match the query in my original dataset are correctly filtered  
> > > when I create the new index (even though I only indexed 3 documents to  
> > > test). I'm completely stumped. I have around 600 indexed documents  
> > > (each one around 20kB, and am running elasticsearch on 64Mb of memory,  
> > > far below the recommended standard configuration. Could malformed  
> > > data in a few of my documents cause the query to not match? Could  
> > > running on 64Mb of memory be the issue?
> > 
> > > On Sep 11, 3:49 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> > 
> > > > This should work. Can you post a recreation (no need for the custom  
> > > > score  
> > > > query you use, just use match\_all). Seehttp://  
> > > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help)
> > 
> > > > On Sun, Sep 11, 2011 at 4:55 AM, Chris  
> > > > [christopherdavidoliva...@gmail.com](mailto:christopherdavidoliva...@gmail.com)wrote:
> > 
> > > > > I've been trying to get these types of queries working for a while,  
> > > > > but no luck. I'm trying to filter documents based on a boolean  
> > > > > value  
> > > > > (basically only show documents where show == true).
> > 
> > > > > Here's my query:
> > 
> > > > > [1158523’s gists · GitHub](https://gist.github.com/1158523)
> > 
> > > > > Documents are being matched where show == false. Any ideas why  
> > > > > this  
> > > > > would happen even though I explicitly say to filter them 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, 3:54am UTC](https://discuss.elastic.co/t/filtering-docs-on-boolean-value/5344/7 "2017-07-06T03:54:44Z")

</div>


