Package org.apache.lucene.search

Examples of org.apache.lucene.search.Scorer


    // NOTE: acceptDocs applies (and is checked) only in the
    // parent document space
    @Override
    public Scorer scorer(AtomicReaderContext readerContext, Bits acceptDocs) throws IOException {

      final Scorer childScorer = childWeight.scorer(readerContext, readerContext.reader().getLiveDocs());
      if (childScorer == null) {
        // No matches
        return null;
      }

      final int firstChildDoc = childScorer.nextDoc();
      if (firstChildDoc == DocIdSetIterator.NO_MORE_DOCS) {
        // No matches
        return null;
      }
View Full Code Here


    @Test
    public void scorerShouldSkipAdjacentDocsIfScoredByOperandScorer() throws IOException {
        IndexReader reader = mock(IndexReader.class);
        stub(reader.isDeleted(anyInt())).toReturn(false);
        stub(reader.maxDoc()).toReturn(10);
        Scorer operandScorer = new MockScorer(0, 1, 2, 3, 4);
        Scorer notScorer = new NotQuery.NotScorer(operandScorer, reader);
        assertScores(notScorer, 5, 6, 7, 8, 9);
    }
View Full Code Here

    @Test
    public void scorerShouldSkipDocsAtEndIfScoredByOperandScorer() throws IOException {
        IndexReader reader = mock(IndexReader.class);
        stub(reader.isDeleted(anyInt())).toReturn(false);
        stub(reader.maxDoc()).toReturn(10);
        Scorer operandScorer = new MockScorer(8, 9);
        Scorer notScorer = new NotQuery.NotScorer(operandScorer, reader);
        assertScores(notScorer, 0, 1, 2, 3, 4, 5, 6, 7);
    }
View Full Code Here

    @Test
    public void scorerShouldScoreFirstDocsIfNotScoredByOperandScorer() throws IOException {
        IndexReader reader = mock(IndexReader.class);
        stub(reader.isDeleted(anyInt())).toReturn(false);
        stub(reader.maxDoc()).toReturn(10);
        Scorer operandScorer = new MockScorer(2, 3, 4);
        Scorer notScorer = new NotQuery.NotScorer(operandScorer, reader);
        assertScores(notScorer, 0, 1, 5, 6, 7, 8, 9);
    }
View Full Code Here

    @Test
    public void scorerShouldScoreNonAdjacentDocsNotScoredByOperandScorer() throws IOException {
        IndexReader reader = mock(IndexReader.class);
        stub(reader.isDeleted(anyInt())).toReturn(false);
        stub(reader.maxDoc()).toReturn(10);
        Scorer operandScorer = new MockScorer(2, 4, 8);
        Scorer notScorer = new NotQuery.NotScorer(operandScorer, reader);
        assertScores(notScorer, 0, 1, 3, 5, 6, 7, 9);
    }
View Full Code Here

    IndexSearcher searcher = new IndexSearcher(reader);
    for (Entry<Query, Integer> entry : deletesFlushed.queries.entrySet()) {
      Query query = entry.getKey();
      int limit = entry.getValue().intValue();
      Weight weight = query.weight(searcher);
      Scorer scorer = weight.scorer(reader, true, false);
      if (scorer != null) {
        while(true)  {
          int doc = scorer.nextDoc();
          if (((long) docIDStart) + doc >= limit)
            break;
          reader.deleteDocument(doc);
          any = true;
        }
View Full Code Here

      // Pass true for "scoresDocsInOrder", because we
      // require in-order scoring, even if caller does not,
      // since we call advance on the valSrcScorers.  Pass
      // false for "topScorer" because we will not invoke
      // score(Collector) on these scorers:
      Scorer subQueryScorer = subQueryWeight.scorer(reader, true, false);
      if (subQueryScorer == null) {
        return null;
      }
      Scorer[] valSrcScorers = new Scorer[valSrcWeights.length];
      for(int i = 0; i < valSrcScorers.length; i++) {
View Full Code Here

    }

    @Override
    public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
      // Pass scoreDocsInOrder true, topScorer false to our sub:
      final Scorer childScorer = childWeight.scorer(reader, true, false);

      if (childScorer == null) {
        // No matches
        return null;
      }

      final int firstChildDoc = childScorer.nextDoc();
      if (firstChildDoc == DocIdSetIterator.NO_MORE_DOCS) {
        // No matches
        return null;
      }
View Full Code Here

      public Similarity getSimilarity(Searcher s) {
        return sim;
      }
      };

    Scorer spanScorer = searcher.createNormalizedWeight(snq).scorer(searcher.getIndexReader(), true, false);

    assertTrue("first doc", spanScorer.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
    assertEquals("first doc number", spanScorer.docID(), 11);
    float score = spanScorer.score();
    assertTrue("first doc score should be zero, " + score, score == 0.0f);
    assertTrue("no second doc", spanScorer.nextDoc() == DocIdSetIterator.NO_MORE_DOCS);
  }
View Full Code Here

    }

    @Override
    public Scorer scorer(IndexReader reader, boolean scoreDocsInOrder, boolean topScorer) throws IOException {
      // Pass scoreDocsInOrder true, topScorer false to our sub:
      final Scorer parentScorer = parentWeight.scorer(reader, true, false);

      if (parentScorer == null) {
        // No matches
        return null;
      }
View Full Code Here

TOP

Related Classes of org.apache.lucene.search.Scorer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.