Package org.apache.lucene.search

Examples of org.apache.lucene.search.Hits.score()


    message("--------------------------------------");
    for (int start = 0; start < hits.length(); start += HITS_PER_PAGE) {
      int end = Math.min(hits.length(), start + HITS_PER_PAGE);
      for (int ii = start; ii < end; ii++) {
        Document doc = hits.doc(ii);
        message("---------------- " + (ii + 1) + " score:" + hits.score(ii) + "---------------------");
        printHit(doc);
        if (showTokens) {
          invertDocument(doc);
        }
        if (explain) {
View Full Code Here


  private void queryTest(Query query) throws IOException {
    Hits parallelHits = parallel.search(query);
    Hits singleHits = single.search(query);
    assertEquals(parallelHits.length(), singleHits.length());
    for(int i = 0; i < parallelHits.length(); i++) {
      assertEquals(parallelHits.score(i), singleHits.score(i), 0.001f);
      Document docParallel = parallelHits.doc(i);
      Document docSingle = singleHits.doc(i);
      assertEquals(docParallel.get("f1"), docSingle.get("f1"));
      assertEquals(docParallel.get("f2"), docSingle.get("f2"));
      assertEquals(docParallel.get("f3"), docSingle.get("f3"));
View Full Code Here

    Hits h = s.search(q);
    assertEquals("All docs should be matched!",N_DOCS,h.length());
    String prevID = "ID"+(N_DOCS+1); // greater than all ids of docs in this test
    for (int i=0; i<h.length(); i++) {
      String resID = h.doc(i).get(ID_FIELD);
      log(i+".   score="+h.score(i)+"  -  "+resID);
      log(s.explain(q,h.id(i)));
      assertTrue("res id "+resID+" should be < prev res id "+prevID, resID.compareTo(prevID)<0);
      prevID = resID;
    }
  }
View Full Code Here

      ? "IE"   // greater than all ids of docs in this test ("ID0001", etc.)
      : "IC"// smaller than all ids of docs in this test ("ID0001", etc.)
         
    for (int i=0; i<h.length(); i++) {
      String resID = h.doc(i).get(ID_FIELD);
      log(i+".   score="+h.score(i)+"  -  "+resID);
      log(s.explain(q,h.id(i)));
      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

        o.println("found: " + len + " documents matching");
        o.println();
        for (int i = 0; i < Math.min(25, len); i++) {
            Document d = hits.doc(i);
      String summary = d.get( "summary");
            o.println("score  : " + hits.score(i));
            o.println("url    : " + d.get("url"));
            o.println("\ttitle  : " + d.get("title"));
      if ( summary != null)
        o.println("\tsummary: " + d.get("summary"));
            o.println();
View Full Code Here

        for (i = 0; i < hits.length() && results.size() < RESULTS_PER_PAGE; i++) {
          Document doc = hits.doc(i);
          String key = doc.get("visibility")+"/"+doc.get("organisation")+"/"+doc.get("module")+"/"+doc.get("fqcn");
          Hit hit = (Hit) h.get(key);
          if (hit == null) {
            hit = new Hit(doc.get("visibility"), doc.get("organisation"), doc.get("module"), doc.get("fqcn"), hits.score(i));
            h.put(key, hit);
            if (countModuleHit >= startIndex) {
              results.add(hit);
            }
            countModuleHit++;
View Full Code Here

      ? "IE"   // greater than all ids of docs in this test ("ID0001", etc.)
      : "IC"// smaller than all ids of docs in this test ("ID0001", etc.)
         
    for (int i=0; i<h.length(); i++) {
      String resID = h.doc(i).get(ID_FIELD);
      log(i+".   score="+h.score(i)+"  -  "+resID);
      log(s.explain(q,h.id(i)));
      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

      for (int start = 0; start < hits.length(); start += HITS_PER_PAGE) {
        int end = Math.min(hits.length(), start + HITS_PER_PAGE);
        for (int i = start; i < end; i++) {

          if (raw) {                              // output raw format
            System.out.println("doc="+hits.id(i)+" score="+hits.score(i));
            continue;
          }

          Document doc = hits.doc(i);
          String path = doc.get("path");
View Full Code Here

    Hits h = s.search(q);
    assertEquals("All docs should be matched!",N_DOCS,h.length());
    String prevID = "ID"+(N_DOCS+1); // greater than all ids of docs in this test
    for (int i=0; i<h.length(); i++) {
      String resID = h.doc(i).get(ID_FIELD);
      log(i+".   score="+h.score(i)+"  -  "+resID);
      log(s.explain(q,h.id(i)));
      assertTrue("res id "+resID+" should be < prev res id "+prevID, resID.compareTo(prevID)<0);
      prevID = resID;
    }
  }
View Full Code Here

        o.println("found: " + len + " documents matching");
        o.println();
        for (int i = 0; i < Math.min(25, len); i++) {
            Document d = hits.doc(i);
      String summary = d.get( "summary");
            o.println("score  : " + hits.score(i));
            o.println("url    : " + d.get("url"));
            o.println("\ttitle  : " + d.get("title"));
      if ( summary != null)
        o.println("\tsummary: " + d.get("summary"));
            o.println();
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.