Lucene: Can I run a query against few specific docs of the collection only?
Can I run a query against few 开发者_Python百科specific docs of the collection only ? Can I filter the built collection according to documents fields content ?
For example I would like to query over documents having field2 = "abc".
thanks
Sure -- use a Filter. See http://lucene.apache.org/java/3_0_1/api/core/org/apache/lucene/search/QueryWrapperFilter.html
The code will look something like:
QueryParser qp = ...
Filter filter = new QueryWrapperFilter(qp.parse("field2:abc"));
// pass filter to searcher.search()
精彩评论