If I understand correctly, I believe you would want to use a TermInSetQuery
query.  An example usage can be found here
https://github.com/zuliaio/zuliasearch/blob/main/zulia-server/src/main/java/io/zulia/server/index/ZuliaIndex.java#L398.


You can also check out the usage of KnnVectorQuery here:
https://github.com/zuliaio/zuliasearch/blob/main/zulia-server/src/main/java/io/zulia/server/index/ZuliaIndex.java#L419
noting that in this case the getPreFilter method a few lines below uses a
BooleanQuery.Builder.

As noted in TermsInSetQuery (
https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java#L62)
multiple terms could be represented as a boolean query with Occur.SHOULD.

~Matt

On Wed, Aug 31, 2022 at 11:15 AM Michael Wechner <michael.wech...@wyona.com>
wrote:

> Hi
>
> I am currently filtering a KnnVectorQuery as follows
>
> Query filter =new TermQuery(new Term(CLASSIFICATION_FIELD,
> classification));
> query =new KnnVectorQuery(VECTOR_FIELD, queryVector, k, filter);
>
> but it is not clear to me how I can filter for multiple terms.
>
> Should I subclass MultiTermQuery and use as filter, just as I use
> TermQuery as filter above?
>
> Thanks
>
> Michael
>

Reply via email to