Reputation: 23567
I want to construct a Lucene query that only matches documents with exactly the terms I specify: no fewer, and no more. The "no fewer" part is easy: a BooleanQuery with all mandatory terms. However, I'm not sure how to do the "no more" part. In essence what I need is a query which says "the result documents cannot have any terms other than what I've specified in the query." Any ideas? Thanks!
Upvotes: 3
Views: 5250
Reputation: 5354
I think you can approach this problem as follows:
doc1: "lorem ipsum", doc2: "lorem ipsum dolor", doc3: "lorem ipsum lorem"
It will produce the following values for them
doc1: "ipsum lorem", doc2: "dolor ipsum lorem", doc3: "ipsum lorem"
The code to achieve this would be too long to fit in the answer, but I hope you get the general idea -- to create a field that you can match fully against.
Upvotes: 5