Package org.apache.lucene.search

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


        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


    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

        double rsLng = NumericUtils.prefixCodedToDouble(d.get(lngField));
        Double geo_distance = distances.get(hits.id(i));
       
        double distance = DistanceUtils.getInstance().getDistanceMi(lat, lng, rsLat, rsLng);
        double llm = DistanceUtils.getInstance().getLLMDistance(lat, lng, rsLat, rsLng);
        System.out.println("Name: "+ name +", Distance (res, ortho, harvesine):"+ distance +" |"+ geo_distance +"|"+ llm +" | score "+ hits.score(i));
        assertTrue(Math.abs((distance - llm)) < 1);
        assertTrue((distance < miles ));
       
      }
    }
View Full Code Here

            if (limit == 0) {
                limit = max;
            }
            for (int i = 0; i < limit && i + offset < max; i++) {
                Document doc = hits.doc(i + offset);
                float score = hits.score(i + offset);
                //## LUCENE2 end ##
            /*## LUCENE3 begin ##
            // take a reference as the searcher may change
            Searcher searcher = access.searcher;
            // reuse the same analyzer; it's thread-safe;
View Full Code Here

    try {
      QueryParser qp = new QueryParser( "id", new StandardAnalyzer() );
      Query query = qp.parse( "title:Action OR Abstract:Action" );
      Hits hits = searcher.search( query );
      assertEquals( 2, hits.length() );
      assertTrue( hits.score( 0 ) == 2 * hits.score( 1 ) );
      assertEquals( "Hibernate in Action", hits.doc( 0 ).get( "title" ) );
    }
    finally {
      if ( searcher != null ) searcher.close();
    }
View Full Code Here

    try {
      QueryParser qp = new QueryParser( "id", new StandardAnalyzer() );
      Query query = qp.parse( "title:Action OR Abstract:Action" );
      Hits hits = searcher.search( query );
      assertEquals( 2, hits.length() );
      assertTrue( hits.score( 0 ) == 2 * hits.score( 1 ) );
      assertEquals( "Hibernate in Action", hits.doc( 0 ).get( "title" ) );
    }
    finally {
      if ( searcher != null ) searcher.close();
    }
View Full Code Here

            {
              Document doc = hits.doc(i);
         
            addFieldsToParsedObject(doc, result);
           
            result.setScore(hits.score(i));
            Field type = doc.getField(ParsedObject.FIELDNAME_TYPE);
            if(type != null)
            {
                result.setType(type.stringValue());
            }
View Full Code Here

            {
              Document doc = hits.doc(i);
         
            addFieldsToParsedObject(doc, result);
           
            result.setScore(hits.score(i));
            Field type = doc.getField(ParsedObject.FIELDNAME_TYPE);
            if(type != null)
            {
                result.setType(type.stringValue());
            }
View Full Code Here

            {
              Document doc = hits.doc(i);
         
            addFieldsToParsedObject(doc, result);
           
            result.setScore(hits.score(i));
            Field type = doc.getField(ParsedObject.FIELDNAME_TYPE);
            if(type != null)
            {
                result.setType(type.stringValue());
            }
View Full Code Here

        for (int i = offset; list.size() < limit && i < h.length(); i++) {
            HashMap map = new HashMap();
            for (int x = 0; x < attrib.length; x++) {
                map.put(attrib[x], h.doc(i).get(attrib[x]));
            }
            map.put("score", new Float(h.score(i)));
            list.add(map);
        }

        return list;
    }
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.