toastdriven/django-haystack — pull request #1093 by joestump (2014-10-23 02:39:52+00:00)
Title: Fix boolean values for Elasticsearch

#### What's this PR do?

It makes `ElasticsearchSearchBackend._from_python()` treat boolean values the same way that `pysolr.Solr._from_python()` does.

#### Where should the reviewer start?

With the changes made to `ElasticsearchSearchBackend._from_python()` and the tests. It should be noted I changed one test in the ES test suite to match the Solr one.

#### How should this be manually tested?

1. Load up a shell with `./manage.py shell`
2. Create an `SearchQuerySet` instance and `filter` it by a `BooleanField` for a given model (e.g. `sqs = SearchQuerySet().models(MyModel).filter(my_boolean_field=False)`).
3. The output of `sqs.query.build_query()` should be `my_boolean_field:(false)` and not `my_boolean_field:(False)`.

#### Any background context you want to provide?

This discrepancy meant you had to effectively convert booleans to a string to use filtering on boolean values in Elasticsearch. I'm not sure if this was a conscious decision or not, but I did find it curious that the Solr backend behaved in opposition to how the ES backend did. I also believe this makes for a more Pythonic interface to instances of `SearchQuerySet` backed by the ES backend.

#### What are the relevant tickets?

This supersedes #979.

#### What gif best describes this PR or how it makes you feel?

![](http://media.giphy.com/media/dmBOWkIej7RAY/giphy.gif)

p.s. I modeled this PR on [a template we use at work I find useful](http://quickleft.com/blog/pull-request-templates-make-code-review-easier).