PUT my_index/my_type/1
{
"full_text": "This is the city where I live",
"exact_value": "MILAN"
}
What I want, it is to create a query that can be logically expressed as: full_text:CONTAINS('live') OR exact_value:CONTAINS('MILAN')
But I want to search full_text in the query context while exact_value in the filter context
I tried with the following query but it doesn't work (replacing MILAN with ROME is the prove)
I want to achieve a logical OR between two fields but one using the query context and the other one using the filter context. I want to use the filter context to improve performance as suggested in the documentation.
But this works the other way around: you don't decide to put a query in a filter context to make it faster, you need to define a query that meets your needs and then elastisearch will figure out the filter parts and potentially make it faster by doing less work and caching. So if you don't really care about scoring, you could put your exact value query under a constant_score query. This way scores won't be needed and your query will execute in a filter context. This will however change the scoring.
I think the more general issue is that filters are aimed at making the set of potential candidates smaller. While here you want to use a filter in a disjunction, meaning that documents are not required to match the filter in order to match.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.