bennylope / elasticstack

:card_index: Configurable indexing and other extras for Haystack (with ElasticSearch biases)
BSD 2-Clause "Simplified" License
127 stars 31 forks source link

Logic around DEFAULT_ANALYZER is a bit off #7

Closed joestump closed 9 years ago

joestump commented 10 years ago

Took quite a while for me to figure out why I was getting "analyzer": None for some of my mappings. This line for setting the analyzer and this line from ConfigurableFieldMixin conspired to make this happen. That getattr will always return true because the kwargs.pop defaults to None and sets the attribute. The default setting is never triggered when this happens, which results in field_class.analyzer being a valid attribute set to None.

I think one of two things should probably happen:

If you let me know which one you think is correct, I'll try and get a PR wrapped up soon.

joestump commented 10 years ago

TIL: If you set analyzer to null, Elasticsearch will remove all analyzer and index settings from the field mappings configuration on the server.

bennylope commented 10 years ago

In this case I think the most sensible approach would be to simply raise an exception is not analyzer is provided.