Package org.apache.lucene.search

Examples of org.apache.lucene.search.IndexSearcher.explain()


    ScoreDoc sd[] = td.scoreDocs;
    for (int i=0; i<sd.length; i++) {
      float score = sd[i].score;
      String id = s.getIndexReader().document(sd[i].doc).get(ID_FIELD);
      log("-------- "+i+". Explain doc "+id);
      log(s.explain(q,sd[i].doc));
      float expectedScore =  N_DOCS-i;
      assertEquals("score of result "+i+" shuould be "+expectedScore+" != "+score, expectedScore, score, TEST_SCORE_TOLERANCE_DELTA);
      String expectedId =  inOrder
        ? id2String(N_DOCS-i) // in-order ==> larger  values first
        : id2String(i+1);     // reverse  ==> smaller values first
View Full Code Here


          String docs = "";
          for (int i = 0; i < hits.scoreDocs.length; i++)
          {
            int docid = hits.scoreDocs[i].doc;
            float score = hits.scoreDocs[i].score;
            Explanation exp = searcher.explain(q, docid);
            Document doc = reader.document(docid);
            long uid = reader.getUID(docid);
            docs = docs + "UID: " + formatter.format(uid) + "\ndocid(in reader): " + formatter.format(docid) + "\nscore: " + score + "\n\n";
            docstr = docstr + "UID: " + formatter.format(uid) + "\ndocid(in reader): " + formatter.format(docid) + "\nscore: " + score + "\n" + doc + "\n" + exp + "\n\n";
          }
View Full Code Here

    // test slop:
    query3.setSlop(1);
    result = searcher.search(query3, null, 1000).scoreDocs;

    // just make sure no exc:
    searcher.explain(query3, 0);

    assertEquals(3, result.length); // blueberry pizza, bluebird pizza, bluebird foobar pizza

    MultiPhraseQuery query4 = new MultiPhraseQuery();
    try {
View Full Code Here

    ScoreDoc[] hits = searcher.search(q, null, 1000).scoreDocs;
   
    assertEquals("Wrong number of hits", 2, hits.length);
   
    // just make sure no exc:
    searcher.explain(q, 0);
   
    writer.close();
    searcher.close();
    reader.close();
    indexStore.close();
View Full Code Here

    q.add(new Term[] {new Term("body", "nope"), new Term("body", "nope")});
    assertEquals("Wrong number of hits", 0,
        searcher.search(q, null, 1).totalHits);
   
    // just make sure no exc:
    searcher.explain(q, 0);
   
    writer.close();
    searcher.close();
    reader.close();
    indexStore.close();
View Full Code Here

  public Explanation explain(Query query, int doc) throws CorruptIndexException, IOException, InterruptedException {
    IndexSearcher searcher = getIndexSearcher();
    _indexSearcherSemaphore.acquire();
    try {
      return searcher.explain(query, doc);
    } finally {
      _indexSearcherSemaphore.release();
    }
  }
View Full Code Here

            : "IC"// smaller than all ids of docs in this test ("ID0001", etc.)

    for (int i = 0; i < h.length; i++) {
      String resID = s.doc(h[i].doc).get(ID_FIELD);
      log(i + ".   score=" + h[i].score + "  -  " + resID);
      log(s.explain(q, h[i].doc));
      if (inOrder) {
        assertTrue("res id " + resID + " should be < prev res id " + prevID, resID.compareTo(prevID) < 0);
      } else {
        assertTrue("res id " + resID + " should be > prev res id " + prevID, resID.compareTo(prevID) > 0);
      }
View Full Code Here

    ScoreDoc sd[] = td.scoreDocs;
    for (int i = 0; i < sd.length; i++) {
      float score = sd[i].score;
      String id = s.getIndexReader().document(sd[i].doc).get(ID_FIELD);
      log("-------- " + i + ". Explain doc " + id);
      log(s.explain(q, sd[i].doc));
      float expectedScore = N_DOCS - i - 1;
      assertEquals("score of result " + i + " shuould be " + expectedScore + " != " + score, expectedScore, score, TEST_SCORE_TOLERANCE_DELTA);
      String expectedId = inOrder
              ? id2String(N_DOCS - i) // in-order ==> larger  values first
              : id2String(i + 1);     // reverse  ==> smaller values first
View Full Code Here

    // test slop:
    query3.setSlop(1);
    result = searcher.search(query3, null, 1000).scoreDocs;
   
    // just make sure no exc:
    searcher.explain(query3, 0);
   
    assertEquals(3, result.length); // blueberry pizza, bluebird pizza, bluebird
                                    // foobar pizza
   
    MultiPhraseQuery query4 = new MultiPhraseQuery();
View Full Code Here

    ScoreDoc[] hits = searcher.search(q, null, 1000).scoreDocs;
   
    assertEquals("Wrong number of hits", 2, hits.length);
   
    // just make sure no exc:
    searcher.explain(q, 0);
   
    writer.close();
    reader.close();
    indexStore.close();
  }
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.