liberation / django-elasticsearch

Simple wrapper around elasticsearch-py to index/search a django Model.
MIT License
212 stars 73 forks source link

value.lower() prevents correctly execute request es.filter(). #49

Open onegreyonewhite opened 8 years ago

onegreyonewhite commented 8 years ago

This is very strange action. Why are you do this? I`m saving my data with some upper symbols like "hrStorageUsed". This action is necessary?

lauxley commented 8 years ago

Hi, good catch, it probably comes from a special mapping i had or something. Also the doc seems to be wrong:

Also by default, filters are case insensitive, if you have a case sensitive tokenizer, you need to instantiate EsQueryset with ignore_case=False.

It is actually the exact opposite of the truth i believe, filters are case sensitive unless you use the lowercase filter on an analyzed field ! And the ignore_case argument to EsQueryset doesn't even exists yet.

This is explained in details here : https://www.elastic.co/guide/en/elasticsearch/guide/current/_finding_exact_values.html#_term_query_with_text

Maybe it would be nice to raise something (a warning at least) when trying to .filter() on an analyzed text field ?

onegreyonewhite commented 8 years ago

Maybe it would be nice to raise something (a warning at least) when trying to .filter() on an analyzed text field ? Nice idea. I was fix this on my project by create EsQueryset class and remove this action.

lauxley commented 8 years ago

I opened a PR https://github.com/liberation/django-elasticsearch/pull/51, it should solve the problem along with some other filters issues (maybe even #50 but i didn't make a test case yet).

onegreyonewhite commented 8 years ago

This issue could be closed if PR #51 will merged.