And the user may choose to only search for 1, or 2, or 3, or any combination of them, for example, 2 and 3.
For example:
user chooses 1, it will not match the above doc
user chooses 2, it will match
user chooses 3, it will not match
user chooses 2 and 3, it will match
When we use TermsQuery, I believe the use case is the opposite. As I understand it, the document would have any combination of of the category ids, like [2, 3], and the client/consumer will provide any combination to match.
A document will match if it contains at least one of the terms
If your use case is exactly like the example you provided, you will only retrieve the document if there is at least one match in the list of IDs.
Are you sure that the Terms query didn't work?
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.