org.ceryle.util.search
Class SearchHit

java.lang.Object
  extended by org.ceryle.util.search.SearchHit

public class SearchHit
extends Object

A class as a struct containing information about a search hit.

Since:
JDK1.4
Version:
$Id: SearchHit.java,v 1.10 2007-06-20 01:28:34 altheim Exp $
Author:
Murray Altheim

Field Summary
 org.apache.lucene.document.Document doc
           
 String html
           
protected static ColorLookupTable m_clut
          The ColorLookupTable used to supply colors for the score display.
protected static String[] m_scoreColors
           
static int maxHits
          Maximum number of hits to return.
 String path
           
static String PROPERTY_maxSearchHits
          The identifier of the property containing the maximum number of displayed hits.
static float resultOffset
          An offset added to the score so that Lucene's result reaches 100 (1.0F) for reasonably-close searches.
 float score
           
 
Constructor Summary
SearchHit(org.apache.lucene.document.Document doc, float score)
          Constructor with Lucene Document and score (match rating).
 
Method Summary
 Color getColorForScore()
          Return a Color from the ColorLookupTable based on this SearchHit's score.
 String getColorSpecForScore()
          Return a color specification from the array based on this SearchHit's score.
 String getDateString()
          Return a formatted date, provided an encoded String (as stored by the search engine).
protected  String getScoreRepresentation()
          Returns a String representing the score.
 String getScoreText()
          Returns the String used to display the score, including any markup.
static SearchHit[] getSearchHits(org.apache.lucene.search.Hits hits)
          Return an array of SearchHit objects, each representing a search hit.
 String getSystemId()
          Returns the String used to display the document identifier, including any markup.
 String getSystemIdText()
          Returns the String used to display the document identifier, including any markup.
 String getTitle()
          Returns the title String for the hit document.
 String toString()
          Return a String respresentation of this search result suitable for display in a list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTY_maxSearchHits

public static final String PROPERTY_maxSearchHits
The identifier of the property containing the maximum number of displayed hits. (The engine may return more, but they won't be displayed.)

See Also:
Constant Field Values

maxHits

public static int maxHits
Maximum number of hits to return. The default is 50; if -1, all hits are returned.


resultOffset

public static float resultOffset
An offset added to the score so that Lucene's result reaches 100 (1.0F) for reasonably-close searches. After some experimentation, the default is set to 0.35.


path

public final String path

score

public float score

html

public String html

doc

public org.apache.lucene.document.Document doc

m_clut

protected static ColorLookupTable m_clut
The ColorLookupTable used to supply colors for the score display. This CLUT must have at least 10 colors or an exception will be thrown.


m_scoreColors

protected static String[] m_scoreColors
Constructor Detail

SearchHit

public SearchHit(org.apache.lucene.document.Document doc,
                 float score)
Constructor with Lucene Document and score (match rating).

Method Detail

getSearchHits

public static SearchHit[] getSearchHits(org.apache.lucene.search.Hits hits)
                                 throws IOException
Return an array of SearchHit objects, each representing a search hit. Returns an empty array rather than null.

Throws:
IOException

getDateString

public String getDateString()
Return a formatted date, provided an encoded String (as stored by the search engine). This returns an empty string rather than failing if the date can't be converted for any reason.


getColorForScore

public Color getColorForScore()
Return a Color from the ColorLookupTable based on this SearchHit's score.


getColorSpecForScore

public String getColorSpecForScore()
Return a color specification from the array based on this SearchHit's score. These generally run from about 0.10 and greater for a solid hit, down to 0.03 or less for glances. The threshold for each range is set here.


getScoreRepresentation

protected String getScoreRepresentation()
Returns a String representing the score. This converts the score value to a more reasonable representation than the floating point result from Lucene. Currently, this returns a percentage value.


getScoreText

public String getScoreText()
Returns the String used to display the score, including any markup.


getSystemId

public String getSystemId()
Returns the String used to display the document identifier, including any markup.


getSystemIdText

public String getSystemIdText()
Returns the String used to display the document identifier, including any markup.


getTitle

public String getTitle()
Returns the title String for the hit document.


toString

public String toString()
Return a String respresentation of this search result suitable for display in a list. This includes HTML markup.

Overrides:
toString in class Object


The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.