Closed joestump closed 9 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.
In this case I think the most sensible approach would be to simply raise an exception is not analyzer
is provided.
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. Thatgetattr
will always return true because thekwargs.pop
defaults toNone
and sets the attribute. The default setting is never triggered when this happens, which results infield_class.analyzer
being a valid attribute set toNone
.I think one of two things should probably happen:
getattr(field_class, 'analyzer', self.DEFAULT_ANALYZER) is None
and, if so, set it toself.DEFAULT_ANALYZER
.ValueError
orhaystack.exceptions.SearchFieldError
if someone doesn't provideanalyzer
in theCharField
'skwargs
.If you let me know which one you think is correct, I'll try and get a PR wrapped up soon.