[英]Search documents in lucene that do not contain a field
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. 不知道我是否可以为此使用QueryWrapperFilter。 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.
寻找更好的方法,谢谢。
FieldValueFilter ,带有否定标志。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.