@Override
    public Scorer scorer(
        AtomicReaderContext context, boolean scoreDocsInOrder, boolean topScorer, Bits acceptDocs)
        throws IOException {
      DocIdSet parentsSet = parentFilter.getDocIdSet(context, acceptDocs);
      if (DocIdSets.isEmpty(parentsSet) || remaining == 0) {
        return null;
      }

      BytesValues bytesValues = parentChildIndexFieldData.load(context).getBytesValues(parentType);
      if (bytesValues == null) {
        return null;
      }

      // We can't be sure of the fact that liveDocs have been applied, so we apply it here. The
      // "remaining"
      // count down (short circuit) logic will then work as expected.
      DocIdSetIterator parentsIterator =
          BitsFilteredDocIdSet.wrap(parentsSet, context.reader().getLiveDocs()).iterator();
      switch (scoreType) {
        case AVG:
          return new AvgParentScorer(
              this, bytesValues, parentIds, scores, occurrences, parentsIterator);
        default:
          return new ParentScorer(this, bytesValues, parentIds, scores, parentsIterator);
      }
    }
    @Override
    public Scorer scorer(LeafReaderContext context, Bits acceptDocs) throws IOException {
      if (remaining == 0) {
        return null;
      }

      if (shortCircuitFilter != null) {
        DocIdSet docIdSet = shortCircuitFilter.getDocIdSet(context, acceptDocs);
        if (!DocIdSets.isEmpty(docIdSet)) {
          DocIdSetIterator iterator = docIdSet.iterator();
          if (iterator != null) {
            return ConstantScorer.create(iterator, this, queryWeight);
          }
        }
        return null;
      }

      DocIdSet parentDocIdSet = this.parentFilter.getDocIdSet(context, acceptDocs);
      if (!DocIdSets.isEmpty(parentDocIdSet)) {
        // We can't be sure of the fact that liveDocs have been applied, so we apply it here. The
        // "remaining"
        // count down (short circuit) logic will then work as expected.
        parentDocIdSet = BitsFilteredDocIdSet.wrap(parentDocIdSet, context.reader().getLiveDocs());
        DocIdSetIterator innerIterator = parentDocIdSet.iterator();
        if (innerIterator != null) {
          LongBitSet parentOrds = collector.parentOrds;
          SortedDocValues globalValues = globalIfd.load(context).getOrdinalsValues(parentType);
          if (globalValues != null) {
            DocIdSetIterator parentIdIterator =
                new ParentOrdIterator(innerIterator, parentOrds, globalValues, this);
            return ConstantScorer.create(parentIdIterator, this, queryWeight);
          }
        }
      }
      return null;
    }
    @Override
    public Scorer scorer(
        AtomicReaderContext context, boolean scoreDocsInOrder, boolean topScorer, Bits acceptDocs)
        throws IOException {
      DocIdSet childrenDocSet = childrenFilter.getDocIdSet(context, acceptDocs);
      if (DocIdSets.isEmpty(childrenDocSet)) {
        return null;
      }
      IdReaderTypeCache idTypeCache =
          searchContext.idCache().reader(context.reader()).type(parentType);
      if (idTypeCache == null) {
        return null;
      }

      return new ChildScorer(this, uidToScore, childrenDocSet.iterator(), idTypeCache);
    }
Beispiel #4
0
    @Override
    public Scorer scorer(
        AtomicReaderContext context, boolean scoreDocsInOrder, boolean topScorer, Bits acceptDocs)
        throws IOException {
      DocIdSet parentsSet = parentFilter.getDocIdSet(context, acceptDocs);
      if (DocIdSets.isEmpty(parentsSet) || remaining == 0) {
        return null;
      }

      IdReaderTypeCache idTypeCache =
          searchContext.idCache().reader(context.reader()).type(parentType);
      // We can't be sure of the fact that liveDocs have been applied, so we apply it here. The
      // "remaining"
      // count down (short circuit) logic will then work as expected.
      DocIdSetIterator parentsIterator =
          BitsFilteredDocIdSet.wrap(parentsSet, context.reader().getLiveDocs()).iterator();
      switch (scoreType) {
        case AVG:
          return new AvgParentScorer(
              this, idTypeCache, uidToScore.v(), uidToCount.v(), parentsIterator);
        default:
          return new ParentScorer(this, idTypeCache, uidToScore.v(), parentsIterator);
      }
    }