# Why the bool query dose not work with filter query?

**URL:** <https://discuss.elastic.co/t/why-the-bool-query-dose-not-work-with-filter-query/7678>\
**Category:** Elasticsearch\
**Created:** [May 14, 2012, 10:17am UTC](https://discuss.elastic.co/t/why-the-bool-query-dose-not-work-with-filter-query/7678 "2012-05-14T10:17:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhouxiang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zhouxiang/32/2775_2.png) [@zhouxiang](https://discuss.elastic.co/u/zhouxiang)\
**Post date:** [May 14, 2012, 10:17am UTC](https://discuss.elastic.co/t/why-the-bool-query-dose-not-work-with-filter-query/7678/1 "2012-05-14T10:17:17Z")

</div>

{  
"query":{  
"filtered": {  
"query":{  
"bool":{  
"must":[  
{  
"term":{"kind":"nps"}  
}  
],  
"must\_not":[  
{  
"text":{"content":"1","operator":"and"}  
}  
]  
}  
},  
"filter":{  
"bool":{  
"must":[  
{  
"term":{"class":"voterlog"}  
}  
]  
}  
}  
}  
},  
"fields":["id"],  
"sort":{  
"time":{"order":"desc"}  
},  
"size":5000  
}'

{"error":"SearchPhaseExecutionException[Failed to execute phase [query], total failure; shardFailures {[mDJbHQAuSdaw403pCGOsdw][extend][0]: SearchParseException[[extend][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"filtered":{"query":{"bool":{"must":[{"term":{"kind":"nps"}}],"must\_not":[{"text":{"content":"1","operator":"and"}}]}},"filter":{"bool":{"must":[{"term":{"class":"voterlog"}}]}}}},"fields":["id"],"sort":{"time":{"order":"desc"}},"size":5000}]]]; nested: QueryParsingException[[extend] [\_na] query malformed, must start with start\_object]; }{[mDJbHQAuSdaw403pCGOsdw][extend][2]: SearchParseException[[extend][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"filtered":{"query":{"bool":{"must":[{"term":{"kind":"nps"}}],"must\_not":[{"text":{"content":"1","operator":"and"}}]}},"filter":{"bool":{"must":[{"term":{"class":"voterlog"}}]}}}},"fields":["id"],"sort":{"time":{"order":"desc"}},"size":5000}]]]; nested: QueryParsingException[[extend] [\_na] query malformed, must start with start\_object]; }{[mDJbHQAuSdaw403pCGOsdw][extend][4]: SearchParseException[[extend][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{"query":{"filtered":{"query":{"bool":{"must":[{"term":{"kind":"nps"}}],"must\_not":[{"text":{"content":"1","operator":"and"}}]}},"filter":{"bool":{"must":[{"term":{"class":"voterlog"}}]}}}},"fields":["id"],"sort":{"time":{"order":"desc"}},"size":5000}]]]; nested: QueryParsingException[[extend] [\_na] query malformed, must start with start\_object]; }]","status":500}

why?  
3ks

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [May 14, 2012, 2:06pm UTC](https://discuss.elastic.co/t/why-the-bool-query-dose-not-work-with-filter-query/7678/2 "2012-05-14T14:06:22Z")

</div>

The problem is in the text query. It should be:

```
                "must_not":[ 
                    { 
                        "text":{
                            "content":{
                                "query":"1",
                                "operator":"and"
                            }
                        } 
                    } 
                ] 

```

On Monday, May 14, 2012 6:17:17 AM UTC-4, shinezhou wrote:

> {  
> "query":{  
> "filtered": {  
> "query":{  
> "bool":{  
> "must":[  
> {  
> "term":{"kind":"nps"}  
> }  
> ],  
> "must\_not":[  
> {  
> "text":{"content":"1","operator":"and"}  
> }  
> ]  
> }  
> },  
> "filter":{  
> "bool":{  
> "must":[  
> {  
> "term":{"class":"voterlog"}  
> }  
> ]  
> }  
> }  
> }  
> },  
> "fields":["id"],  
> "sort":{  
> "time":{"order":"desc"}  
> },  
> "size":5000  
> }'
> 
> {"error":"SearchPhaseExecutionException[Failed to execute phase [query],  
> total failure; shardFailures {[mDJbHQAuSdaw403pCGOsdw][extend][0]:  
> SearchParseException[[extend][0]: from[-1],size[-1]: Parse Failure [Failed  
> to parse source  
> [{"query":{"filtered":{"query":{"bool":{"must":[{"term":{"kind":"nps"}}],"must\_not":[{"text":{"content":"1","operator":"and"}}]}},"filter":{"bool":{"must":[{"term":{"class":"voterlog"}}]}}}},"fields":["id"],"sort":{"time":{"order":"desc"}},"size":5000}]]];
> 
> nested: QueryParsingException[[extend] [\_na] query malformed, must start  
> with start\_object]; }{[mDJbHQAuSdaw403pCGOsdw][extend][2]:  
> SearchParseException[[extend][2]: from[-1],size[-1]: Parse Failure [Failed  
> to parse source  
> [{"query":{"filtered":{"query":{"bool":{"must":[{"term":{"kind":"nps"}}],"must\_not":[{"text":{"content":"1","operator":"and"}}]}},"filter":{"bool":{"must":[{"term":{"class":"voterlog"}}]}}}},"fields":["id"],"sort":{"time":{"order":"desc"}},"size":5000}]]];
> 
> nested: QueryParsingException[[extend] [\_na] query malformed, must start  
> with start\_object]; }{[mDJbHQAuSdaw403pCGOsdw][extend][4]:  
> SearchParseException[[extend][4]: from[-1],size[-1]: Parse Failure [Failed  
> to parse source  
> [{"query":{"filtered":{"query":{"bool":{"must":[{"term":{"kind":"nps"}}],"must\_not":[{"text":{"content":"1","operator":"and"}}]}},"filter":{"bool":{"must":[{"term":{"class":"voterlog"}}]}}}},"fields":["id"],"sort":{"time":{"order":"desc"}},"size":5000}]]];
> 
> nested: QueryParsingException[[extend] [\_na] query malformed, must start  
> with start\_object]; }]","status":500}
> 
> why?  
> 3ks
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/why-the-bool-query-dose-not-work-with-filter-query-tp3985487.html](http://elasticsearch-users.115913.n3.nabble.com/why-the-bool-query-dose-not-work-with-filter-query-tp3985487.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![zhouxiang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zhouxiang/32/2775_2.png) [@zhouxiang](https://discuss.elastic.co/u/zhouxiang)\
**Post date:** [May 15, 2012, 12:12am UTC](https://discuss.elastic.co/t/why-the-bool-query-dose-not-work-with-filter-query/7678/3 "2012-05-15T00:12:43Z")

</div>

thanks.  
i got it.

---

<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:28am UTC](https://discuss.elastic.co/t/why-the-bool-query-dose-not-work-with-filter-query/7678/4 "2017-07-06T03:28:54Z")

</div>


