Package org.apache.lucene.search

Examples of org.apache.lucene.search.Scorer


      "{ \"baba\" : \"aaa ccc\" , \"ccc\" \"bbb ccc\" }",
      "{ \"aaa\" : \"aaa bbb ddd\" }",
      "{ \"ddd\" : [ \"bobo\", \"bibi\" ] }"
    );

    final Scorer scorer1 = this.getScorer(
      ntq("bobo").getLuceneProxyQuery()
    );

    assertTrue(scorer1.advance(2) != DocIdSetIterator.NO_MORE_DOCS);
    assertEquals(2, scorer1.docID());
    assertEquals(1, scorer1.freq(), 0);
    assertTrue(scorer1.nextDoc() == DocIdSetIterator.NO_MORE_DOCS);

    final Scorer scorer2 = this.getScorer(
      ntq("baba").getLuceneProxyQuery()
    );
    assertTrue(scorer2.advance(2) == DocIdSetIterator.NO_MORE_DOCS);
  }
View Full Code Here


      "{ \"baba\" : \"bibi ccc\" , \"ccc\" \"bbb ccc\" }",
      "{ \"baba bibi baba bibi\" : \"aaa bbb ddd\" }",
      "{ \"baba bibi\" : \"aaa bbb ddd\" }"
    );

    final Scorer scorer1 = this.getScorer(
      nbq(must("baba", "bibi")).getLuceneProxyQuery()
    );

    assertTrue(scorer1.advance(0) != DocIdSetIterator.NO_MORE_DOCS);
    assertEquals(1, scorer1.docID());
    assertEquals(2, scorer1.freq(), 0);
    final float score1 = scorer1.score();
    assertTrue(scorer1.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
    assertEquals(2, scorer1.docID());
    assertEquals(2, scorer1.freq(), 0);
    final float score2 = scorer1.score();
    assertTrue(score1 > score2);
    assertTrue(scorer1.nextDoc() == DocIdSetIterator.NO_MORE_DOCS);
  }
View Full Code Here

    }

    @Override
    public Scorer scorer(AtomicReaderContext context, boolean scoreDocsInOrder, boolean topScorer, Bits acceptDocs)
        throws IOException {
      Scorer scorer = weight.scorer(context, true, topScorer, acceptDocs);
      if (scorer == null) {
        return null;
      }
      OpenBitSet primeDocBitSet = PrimeDocCache.getPrimeDocBitSet(primeDocTerm, context.reader());
      return new SuperScorer(scorer, primeDocBitSet, originalQueryStr, scoreType);
View Full Code Here

    private int processFacets(int doc) throws IOException {
      if (doc == NO_MORE_DOCS) {
        return doc;
      }
      for (int i = 0; i < facetLength; i++) {
        Scorer facet = facets[i];
        if (facet == null) {
          continue;
        }
        int docID = facet.docID();
        if (docID == NO_MORE_DOCS) {
          continue;
        }
        if (docID == doc) {
          counts.incrementAndGet(i);
        } else if (docID < doc) {
          if (facet.advance(doc) == doc) {
            counts.incrementAndGet(i);
          }
        }
      }
      return doc;
View Full Code Here

      weight.normalize(norm, topLevelBoost);
    }

    @Override
    public Scorer scorer(AtomicReaderContext context, boolean scoreDocsInOrder, boolean topScorer, Bits acceptDocs) throws IOException {
      Scorer scorer = weight.scorer(context, scoreDocsInOrder, topScorer, acceptDocs);
      if (scorer == null) {
        highCpuWait(1);
        return null;
      }
      return new SlowScorer(weight, scorer);
View Full Code Here

      weight.normalize(norm, topLevelBoost);
    }

    @Override
    public Scorer scorer(AtomicReaderContext context, boolean scoreDocsInOrder, boolean topScorer, Bits acceptDocs) throws IOException {
      Scorer scorer = weight.scorer(context, true, topScorer, acceptDocs);
      if (scorer == null) {
        return null;
      }
      return new FacetScorer(scorer, getScorers(context, true, topScorer, acceptDocs), counts);
    }
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

    while(iter.hasNext()) {
      Entry entry = (Entry) iter.next();
      Query query = (Query) entry.getKey();
      int limit = ((Integer) 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

   * this causes problems
   */
  public void testSpanNearScorerSkipTo1() throws Exception {
    SpanNearQuery q = makeQuery();
    Weight w = searcher.createNormalizedWeight(q);
    Scorer s = w.scorer(searcher.getIndexReader(), true, false);
    assertEquals(1, s.advance(1));
  }
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.