jcolibri.extensions.textual.lucene
Class LuceneSearchResult

java.lang.Object
  extended by jcolibri.extensions.textual.lucene.LuceneSearchResult

public class LuceneSearchResult
extends java.lang.Object

Stores the result of a search. It is a list of relevant documents with an assigned score.

Author:
Juan A. Recio-García

Constructor Summary
protected LuceneSearchResult(org.apache.lucene.search.Hits hits, LuceneIndex index)
          Transforms from Lucene result format.
 
Method Summary
 java.lang.String getContent(int position, java.lang.String fieldName)
          Returns the content of a field of the document located in the given position.
 LuceneDocument getDocAt(int position)
          Gets the document in a position inside the results list.
 int getDocPosition(java.lang.String docID)
          Gets the position of a document in the result given its ID.
 float getDocScore(int position, boolean normalized)
          Gets the score obtained by a document located in a position of the result list.
 float getDocScore(java.lang.String docID, boolean normalized)
          Gets the score obtained by a document.
 int getResultLength()
          Returns the number of results
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LuceneSearchResult

protected LuceneSearchResult(org.apache.lucene.search.Hits hits,
                             LuceneIndex index)
                      throws java.io.IOException
Transforms from Lucene result format.

Throws:
java.io.IOException
Method Detail

getDocPosition

public int getDocPosition(java.lang.String docID)
Gets the position of a document in the result given its ID. If that ID is not in the results set this methods returns -1


getDocAt

public LuceneDocument getDocAt(int position)
Gets the document in a position inside the results list.


getDocScore

public float getDocScore(java.lang.String docID,
                         boolean normalized)
Gets the score obtained by a document. It can be normalized to [0..1], that way, the document with max score will have a 1 and the document with min score a 0.


getDocScore

public float getDocScore(int position,
                         boolean normalized)
Gets the score obtained by a document located in a position of the result list. It can be normalized to [0..1], that way, the document with max score will have a 1 and the document with min score a 0.


getContent

public java.lang.String getContent(int position,
                                   java.lang.String fieldName)
Returns the content of a field of the document located in the given position.

Parameters:
position - of the document in the result list
fieldName - that stores the text to return

getResultLength

public int getResultLength()
Returns the number of results


GAIA - Group for Artificial Intelligence Applications
http://gaia.fdi.ucm.es