Hello!
I am trying to create a query to search for different values of a specific field within a timeframe. For example, I want to search for a response with the value “123” OR “321” , AND it was created in the last 5 minutes:
If you combine a should clause with a must clause then any query inside of the should clause is optional. In other words, if a document just matches the query in the must clause, it's also going to be a hit (but with a lower score).
What you want to achieve can be done by making the should clause it's own bool query, and putting that bool query inside the must clause:
Or, alternatively, you can add minimum_should_match to the query. That parameter allows you to specify how many of the queries in the should clause have to match for a document to be considered a hit:
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.