# Haystack SearchQuery boolean filter not working

**URL:** <https://discuss.elastic.co/t/haystack-searchquery-boolean-filter-not-working/9679>\
**Category:** Elasticsearch\
**Created:** [November 12, 2012, 6:48pm UTC](https://discuss.elastic.co/t/haystack-searchquery-boolean-filter-not-working/9679 "2012-11-12T18:48:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Salma\_Hamed](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/salma_hamed/32/2622_2.png) [@Salma\_Hamed](https://discuss.elastic.co/u/Salma_Hamed)\
**Post date:** [November 12, 2012, 6:48pm UTC](https://discuss.elastic.co/t/haystack-searchquery-boolean-filter-not-working/9679/1 "2012-11-12T18:48:25Z")

</div>

I switched from Whoosh to ElasticSearch to be haystack search engine. Now I  
am facing a problem with Elastic search. If I am preforming one filter  
everything is working. But when filter the output I get from the first  
filter it gives me SearchParseException - Failed to parse query [(( AND  
city:(xxx)))]

Here is my code:

filterCity = True  
results = SearchQuerySet().filter(content='Me')if filterCity:  
results = results.filter\_and(city='xxx')

Note this sample code was working using whoosh.

Any Idea how to solve this. Thanks alot in advance

--

---

<div class="post-metadata">

**Author:** ![Chris\_Male](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chris_male/32/2607_2.png) [@Chris\_Male](https://discuss.elastic.co/u/Chris_Male)\
**Post date:** [November 12, 2012, 10:46pm UTC](https://discuss.elastic.co/t/haystack-searchquery-boolean-filter-not-working/9679/2 "2012-11-12T22:46:18Z")

</div>

I think the problem is in Haystack and how it communicates with  
Elasticsearch. Perhaps best to ask their community for help?

On Tuesday, November 13, 2012 7:48:25 AM UTC+13, Salma Hamed wrote:

> I switched from Whoosh to Elasticsearch to be haystack search engine. Now  
> I am facing a problem with Elastic search. If I am preforming one filter  
> everything is working. But when filter the output I get from the first  
> filter it gives me SearchParseException - Failed to parse query [(( AND  
> city:(xxx)))]
> 
> Here is my code:
> 
> filterCity = True  
> results = SearchQuerySet().filter(content='Me')if filterCity:  
> results = results.filter\_and(city='xxx')
> 
> Note this sample code was working using whoosh.
> 
> Any Idea how to solve this. Thanks alot in advance

--

---

<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:04am UTC](https://discuss.elastic.co/t/haystack-searchquery-boolean-filter-not-working/9679/3 "2017-07-06T03:04:40Z")

</div>

Closed on July 6, 2017, 3:04am UTC


