首页 > 解决方案 > Lucene 8.6.1 加入查询没有收集所有加入的记录

问题描述

Lucene 8.6.1 加入查询没有收集所有加入的记录

joinQuery = JoinUtil.createJoinQuery(fromField, false, toField, query, searcher,
                ScoreMode.None);

执行连接查询时,它不会收集所有连接的记录。

 protected void search(List<LeafReaderContext> leaves, Weight weight, Collector collector)
      throws IOException {

    // TODO: should we make this
    // threaded...?  the Collector could be sync'd?
    // always use single thread:
    for (LeafReaderContext ctx : leaves) { // search each subreader
      final LeafCollector leafCollector;
      try {
        **leafCollector = collector.getLeafCollector(ctx);**
      } catch (CollectionTerminatedException e) {
        // there is no doc of interest in this reader context
        // continue with the following leaf
        continue;
      }
      BulkScorer scorer = weight.bulkScorer(ctx);
      if (scorer != null) {
        try {
          scorer.score(leafCollector, ctx.reader().getLiveDocs());
        } catch (CollectionTerminatedException e) {
          // collection was terminated prematurely
          // continue with the following leaf
        }
      }
    }
  }

类似的 joinQuery 在 lucene 4.5.1 中工作

我们是否需要编写自定义收集器来收集 JoinQuery 记录或我们可以收集它的任何其他方式?

//更新

当我在 rewrite 方法中通过 org.apache.lucene.search.MultiTermQueryConstantScoreWrapper 中的连接查询 TermsQuery{field=associatedresourceurifromQuery=+_category:animals} 时,我得到collectedTerms null 并且结果具有MatchNoDocsQuery(“empty BooleanQuery”),任何人都有任何想法,我们是否必须编写任何 CustomCollector 来收集连接查询结果?

提前致谢。

标签: javalucene

解决方案


推荐阅读