Examples of ScoreDoc


Examples of org.apache.lucene.search.ScoreDoc

  public static void assertEquals(TopDocs expected, TopDocs actual) {
    Assert.assertEquals("wrong total hits", expected.totalHits, actual.totalHits);
    Assert.assertEquals("wrong maxScore", expected.getMaxScore(), actual.getMaxScore(), 0.0);
    Assert.assertEquals("wrong hit count", expected.scoreDocs.length, actual.scoreDocs.length);
    for(int hitIDX=0;hitIDX<expected.scoreDocs.length;hitIDX++) {
      final ScoreDoc expectedSD = expected.scoreDocs[hitIDX];
      final ScoreDoc actualSD = actual.scoreDocs[hitIDX];
      Assert.assertEquals("wrong hit docID", expectedSD.doc, actualSD.doc);
      Assert.assertEquals("wrong hit score", expectedSD.score, actualSD.score, 0.0);
      if (expectedSD instanceof FieldDoc) {
        Assert.assertTrue(actualSD instanceof FieldDoc);
        Assert.assertEquals("wrong sort field values",
View Full Code Here

Examples of org.apache.lucene.search.ScoreDoc

      LinkedHashMap<Document, Float> result = new LinkedHashMap<Document, Float>(hits.length);

      // Calculate the number of documents to be fetched
      int num = Math.min(hits.length, count);
      for (int i = 0; i < num; i++) {
        ScoreDoc currentDoc = hits[i];
        if (currentDoc.doc != Integer.MAX_VALUE) {
          log.debug("currentDoc id: " + currentDoc.doc + " ; score: " + currentDoc.score);
          Document doc = searcher.doc(currentDoc.doc);
          // add id field for AdvancedContentHighlighter
          doc.add(new Field("id", hits[i].doc + "", Field.Store.YES, Field.Index.NO));
View Full Code Here

Examples of org.apache.lucene.search.ScoreDoc

    }

    public TopDocs getHits() {
      ScoreDoc[] scoreDocs = new ScoreDoc[hitCount];
      for(int i=0;i<hitCount;i++) {
        scoreDocs[i] = new ScoreDoc(hits[i], Float.NaN);
      }
      return new TopDocs(hitCount, scoreDocs, Float.NaN);
    }
View Full Code Here

Examples of org.apache.lucene.search.ScoreDoc

   * @throws IOException if an I/O error occurred during processing
   * @throws IllegalArgumentException if <code>field</code> was indexed without
   *         {@link IndexOptions#DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS}
   */
  public Map<String,String[]> highlightFields(String fields[], Query query, IndexSearcher searcher, TopDocs topDocs, int maxPassages[]) throws IOException {
    final ScoreDoc scoreDocs[] = topDocs.scoreDocs;
    int docids[] = new int[scoreDocs.length];
    for (int i = 0; i < docids.length; i++) {
      docids[i] = scoreDocs[i].doc;
    }

View Full Code Here

Examples of org.apache.lucene.search.ScoreDoc

  }

  private static void assertTopDocsEquals(ScoreDoc[] scoreDocs1, ScoreDoc[] scoreDocs2) {
    assertEquals(scoreDocs1.length, scoreDocs2.length);
    for (int i = 0; i < scoreDocs1.length; ++i) {
      final ScoreDoc scoreDoc1 = scoreDocs1[i];
      final ScoreDoc scoreDoc2 = scoreDocs2[i];
      assertEquals(scoreDoc1.doc, scoreDoc2.doc);
      assertEquals(scoreDoc1.score, scoreDoc2.score, 0.001f);
    }
  }
View Full Code Here

Examples of org.apache.lucene.search.ScoreDoc

      // hits = searcher.search(query, null, num, new Sort(new SortField("weight", SortField.Type.LONG, true)));

      List<LookupResult> results = new ArrayList<LookupResult>();
      BytesRef scratch = new BytesRef();
      for (int i=0;i<hits.scoreDocs.length;i++) {
        ScoreDoc sd = hits.scoreDocs[i];
        textDV.get(sd.doc, scratch);
        String text = scratch.utf8ToString();
        long score = weightsDV.get(sd.doc);

        BytesRef payload;
View Full Code Here

Examples of org.apache.lucene.search.ScoreDoc

//    }
//    CheckHits.checkHits(random(), q, "", indexSearcher, expectedDocs);

    TopDocs docs = indexSearcher.search(q, 1000);//calculates the score
    for (int i = 0; i < docs.scoreDocs.length; i++) {
      ScoreDoc gotSD = docs.scoreDocs[i];
      float expectedScore = scores[gotSD.doc];
      assertEquals("Not equal for doc "+gotSD.doc, expectedScore, gotSD.score, delta);
    }

    CheckHits.checkExplanations(q, "", indexSearcher);
View Full Code Here

Examples of org.apache.lucene.search.ScoreDoc

          new float[] { 4f, 4f });
    }
  }
 
  void assertHits(Query q, float scores[]) throws Exception {
    ScoreDoc expected[] = new ScoreDoc[scores.length];
    int expectedDocs[] = new int[scores.length];
    for (int i = 0; i < expected.length; i++) {
      expectedDocs[i] = i;
      expected[i] = new ScoreDoc(i, scores[i]);
    }
    TopDocs docs = searcher.search(q, documents.size(),
        new Sort(new SortField("id", SortField.Type.STRING)));
    CheckHits.checkHits(random(), q, "", searcher, expectedDocs);
    CheckHits.checkHitsQuery(q, expected, docs.scoreDocs, expectedDocs);
View Full Code Here

Examples of org.apache.lucene.search.ScoreDoc

    });
    ScoreDoc[] scoreDocs = new ScoreDoc[Math.min(10, hits.size())];
    for (int i = 0; i < scoreDocs.length; i++) {
      Map.Entry<Integer,JoinScore> hit = hits.get(i);
      scoreDocs[i] = new ScoreDoc(hit.getKey(), hit.getValue().score(scoreMode));
    }
    return new TopDocs(hits.size(), scoreDocs, hits.isEmpty() ? Float.NaN : hits.get(0).getValue().score(scoreMode));
  }
View Full Code Here

Examples of org.apache.lucene.search.ScoreDoc

    int actualNum = num / numFactor;

    BytesRef scratch = new BytesRef();
    for (int i = 0; i < hits.scoreDocs.length; i++) {

      ScoreDoc sd = hits.scoreDocs[i];
      textDV.get(sd.doc, scratch);
      String text = scratch.utf8ToString();
      long weight = weightsDV.get(sd.doc);

      BytesRef payload;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.