Package org.apache.lucene.search

Examples of org.apache.lucene.search.ScoreDoc


    // all 10 hits should have score = 4 (max payload value)
    hits = searcher.search(query, null, 100);
    assertTrue("hits is null and it shouldn't be", hits != null);
    assertTrue("should be 10 hits", hits.totalHits == 10);
    for (int j = 0; j < hits.scoreDocs.length; j++) {
      ScoreDoc doc = hits.scoreDocs[j];
      assertTrue(doc.score + " does not equal: " + 4, doc.score == 4);
      Explanation explain = searcher.explain(query, hits.scoreDocs[j].doc);
      String exp = explain.toString();
      assertTrue(exp, exp.indexOf("MaxPayloadFunction") > -1);
      assertTrue(hits.scoreDocs[j].score + " explain value does not equal: " + 4, explain.getValue() == 4f);
View Full Code Here


    // all 10 hits should have score = 2 (min payload value)
    hits = searcher.search(query, null, 100);
    assertTrue("hits is null and it shouldn't be", hits != null);
    assertTrue("should be 10 hits", hits.totalHits == 10);
    for (int j = 0; j < hits.scoreDocs.length; j++) {
      ScoreDoc doc = hits.scoreDocs[j];
      assertTrue(doc.score + " does not equal: " + 2, doc.score == 2);
      Explanation explain = searcher.explain(query, hits.scoreDocs[j].doc);
      String exp = explain.toString();
      assertTrue(exp, exp.indexOf("MinPayloadFunction") > -1);
      assertTrue(hits.scoreDocs[j].score + " explain value does not equal: " + 2, explain.getValue() == 2f);
View Full Code Here

    PayloadNearQuery query;
    TopDocs hits;
    query = newPhraseQuery("field", "nine hundred ninety nine", true, new AveragePayloadFunction());
    hits = searcher.search(query, null, 100);
    assertTrue("hits is null and it shouldn't be", hits != null);
    ScoreDoc doc = hits.scoreDocs[0];
    //    System.out.println("Doc: " + doc.toString());
    //    System.out.println("Explain: " + searcher.explain(query, doc.doc));
    assertTrue("there should only be one hit", hits.totalHits == 1);
    // should have score = 3 because adjacent terms have payloads of 2,4
    assertTrue(doc.score + " does not equal: " + 3, doc.score == 3);
View Full Code Here

    hits = searcher.search(query, null, 100);
    assertTrue("hits is null and it shouldn't be", hits != null);
    // should be only 1 hit - doc 999
    assertTrue("should only be one hit", hits.scoreDocs.length == 1);
    // the score should be 3 - the average of all the underlying payloads
    ScoreDoc doc = hits.scoreDocs[0];
    //    System.out.println("Doc: " + doc.toString());
    //    System.out.println("Explain: " + searcher.explain(query, doc.doc));
    assertTrue(doc.score + " does not equal: " + 3, doc.score == 3)
  }
View Full Code Here

      String aDocs[] = new String[nHitCount]
      float aScores[] = null;
      aScores = new float[nHitCount];
      for( int iHit = 0 ; iHit < nHitCount ; iHit++ )
      {
        ScoreDoc aDoc = aHits.scoreDocs[iHit];
        String aPath = searcher.doc(aDoc.doc).get( "path" );
        aDocs[iHit] = ( aPath != null ) ? aPath : "";
        aScores[iHit] = aDoc.score;
      }
      aScoreOutArray[0] = aScores;
View Full Code Here

            Query queryObj = qp.parse(query);
            TopDocs topdocs = is.search(queryObj, SEARCH_SIZE);
            int total = topdocs.totalHits;
            String[] ids = new String[total];
            for (int i = 0; i < total; i++) {
                ScoreDoc d = topdocs.scoreDocs[i];
                ids[i] = is.doc(d.doc).get(LuceneAuditor.FIELD_ID);
            }
            return ids;
        } catch (ParseException pe) {
            throw (IOException) new IOException("Error parsing query").initCause(pe);
View Full Code Here

            if (_hits.totalHits > 0) {
              for (int i=start-1; i < (start - 1 + length); i++) {
                  if (i >= _hits.scoreDocs.length) {
                      break;
                  }               
                  ScoreDoc doc = _hits.scoreDocs[i];
                  WGContent content = luceneDocToContent(doc, _hits.getMaxScore());
                  if (content != null) {
                      contents.add(content);
                  }
                  else {
View Full Code Here

    private List<DBContentKey> buildContentsList(TopDocs hits, WGACore core, HttpServletRequest request) throws CorruptIndexException, IOException, InterruptedException, WGAPIException {

        List<DBContentKey> contents = new ArrayList<DBContentKey>();
        for (int i=0; i < hits.scoreDocs.length; i++) {
            ScoreDoc scoreDoc = hits.scoreDocs[i];
            Document doc = _core.getLuceneManager().getDocument(scoreDoc.doc);
            String contentKey = doc.get(LuceneManager.INDEXFIELD_CONTENTKEY);
            String dbKey = doc.get(LuceneManager.INDEXFIELD_DBKEY);
            WGDatabase db = core.getContentdbs().get(dbKey);
            if (db != null) {
View Full Code Here

  public String getRawColumn( int columnid ) throws SQLException
    {
        _wasNull = false;
       
    try {
            ScoreDoc    scoreDoc = getScoreDoc();
            int     docID = scoreDoc.doc;
           
      if ( isKeyID( columnid ) ) { return _searcher.doc( docID ).get( getColumnName( columnid ) ); }
      else { throw invalidColumnPosition( columnid ); }
    }
View Full Code Here

    /** Handle long columns */
    public  long    getLong( int columnid throws SQLException
    {
    try {
            ScoreDoc    scoreDoc = getScoreDoc();
            int     docID = scoreDoc.doc;
      if ( isKeyID( columnid ) )
            {
                Number  number = getNumberValue( columnid );

View Full Code Here

TOP

Related Classes of org.apache.lucene.search.ScoreDoc

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.