Hello. I'm using a "term" filter on a nested field, it's working fine. But I'm getting an error when I try to do the same query with "terms" on ES 2.4. Any tips here?
# Working:
{'query': {'filtered': {'filter': {'bool': {'must': [{'term': {'clinic': '7'}}, {'term': {'_deleted': False}}, {'nested': {'query': {'term': {'procedure.name': {'term': 'terapy'}}}, 'path': 'procedure'}}]}}, 'query': {'match_all': {}}}}}
# Not working:
{'query': {'filtered': {'filter': {'bool': {'must': [{'term': {'clinic': '7'}}, {'term': {'_deleted': False}}, {'nested': {'query': {'terms': {'category.pk': {'terms': ['522', '511']}}}, 'path': 'category'}}]}}, 'query': {'match_all': {}}}}}
# Error:
# RequestError: TransportError(400, u'search_phase_execution_exception', u'[terms] query does not support [terms] within lookup element')
Algo, I'm using the lib elasticsearch-dsl to interact with ES on Python. The code is something like:
# Working
search.filter('nested', path='procedure', query=Q('term', procedure__name={'term': procedure_name}))
# Not working
search.filter('nested', path='category', query=Q('terms', category__pk={'terms': category_id}))