Reputation: 1943
I need to search only documents that do not contain a particular field.
I tried this, doesn't work:
BooleanQuery constrainedQuery = new BooleanQuery();
constrainedQuery.add(query, BooleanClause.Occur.MUST);
constrainedQuery.add(new TermQuery(new Term("fieldName")), BooleanClause.Occur.MUST_NOT);
Not sure if I can use QueryWrapperFilter for this either. My current alternative is to search for everything and ignore the documents that contain the field in the hits. Looking for a better way, thank you.
Upvotes: 1
Views: 253