【问题标题】:Lucene: Can I run a query against few specific docs of the collection only?Lucene:我可以只对集合的几个特定文档运行查询吗?
【发布时间】:2011-03-29 10:55:16
【问题描述】:

我可以只针对集合的几个特定文档运行查询吗? 我可以根据文档字段内容过滤构建的集合吗?

例如,我想查询具有 field2 = "abc" 的文档。

谢谢

【问题讨论】:

    标签: lucene


    【解决方案1】:

    当然——使用过滤器。见http://lucene.apache.org/java/3_0_1/api/core/org/apache/lucene/search/QueryWrapperFilter.html

    代码如下所示:

    QueryParser qp = ...
    Filter filter = new QueryWrapperFilter(qp.parse("field2:abc"));
    // pass filter to searcher.search()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-06-27
      • 1970-01-01
      • 1970-01-01
      • 2018-06-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多