开发者

Lucene: Can I run a query against few specific docs of the collection only?

开发者 https://www.devze.com 2023-02-20 07:18 出处:网络
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 ?

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()
0

精彩评论

暂无评论...
验证码 换一张
取 消