Closed onegreyonewhite closed 8 years ago
Hello, the syntax is correct, the must filter of Elasticsearch is mapped to __exact of Django and range to gt, gte, etc.. So it seems that either the query is not generated properly (bug) or the used version of pyelasticsearch is not matching your elasticsearch install ? I will investigate.
I pushed a fix, let me know if it works for you.
Thank you so much! It works! `>> Traps.es.all().filter(time__gte=last.isoformat(), severity="ERROR", server="test")
{'query': {'filtered': {'filter': {'bool': {'must': [{'range': {'time': {'gte': '2016-04-08T11:17:26.100360'}}}, {'term': {'severity': 'ERROR'}}, {'term': {'server': 'test'}}]}}}}, 'size': 1000}
[{u'obj': u'None', u'severity': u'ERROR', u'param': u'test', u'server': u'test', u'time': u'2016-04-08T11:59:43.286331', u'msg': u''}]`
I add "size" to query body in your module, because only 10 results returns basicly. You can add additional attribute in EsIndexable class for development convenience.
Thank you for help and this project :)
Sorry, for my question. How to filter by fields "must" and "range"? I used
q = Traps.es.all().filter(time__gte="now-10d") q.filter(severity="ERROR")
but it tell me raiseHow to get range and must fields filter?
P.S.: query search create
{'query': {'filtered': {'filter': {'range': {'time': {'gte': 'now-10d'}}, 'bool': {'must': [{'term': {'severity': 'error'}}]}}}}}