I'm trying to combine Boolean search using the "must" statement that takes into account the synonyms, currently set up in a synonyms text file during indexing as follows-
Indexing:
data='{"settings": {"index":{"analysis":{"analyzer":{"synonym":{"tokenizer":"whitespace","filter":["synonym"]}},"filter":{"synonym":{"type":"synonym","synonyms_path":"analysis/med_syn.txt"}}}}}}'`
response = requests.put('http://localhost:9200/all_articles_synonyms', headers=headers, data=data)
Search: The following statements work well
Synonym search:
data="{'query': {'match': {'article': {'query': 'search_term1', 'analyzer': 'synonym'}}}}"
Boolean search-individual terms:
data_now={'query': {'bool': {'must': [{'term': {'article': 'search_term1'}}, {'term': {'article': 'search_term2'}}]}}}
Boolean search as list:
data='{"query": {"bool": {"must": [{"terms": {"article":["search_term2", "search_term1"]}}]}}}'
What I'm trying to achieve is a combination of both as in:
data='{"query": {"bool": {"must": [{"terms": {"article":["search_term1","search_term2"], "analyzer": "synonym"}}]}}}'
But this statement gets: >
'{"error":{"root_cause":[{"type":"parsing_exception","reason":"[terms] query does not support [analyzer]","line":1,"col":107}],"type":"parsing_exception","reason":"[terms] query does not support [analyzer]","line":1,"col":107},"status":400}'
Can I rewrite this statement to get the Boolean search results with the synonyms filter? Is there another way I should follow?