org.cdlib.xtf.textEngine
Class QueryResult

Object
  extended by QueryResult

public class QueryResult
extends Object

Represents the results of a query. This consists of a few statistics, followed by an array of document hit(s).

Author:
Martin Haye

Field Summary
 QueryContext context
          Context of the query (including stop word list, and maps for plurals and accents).
private  DecimalFormat decFormat
          Formatter for non-normalized scores
 DocHit[] docHits
          One hit per document
 int endDoc
          Oridinal rank of the last document hit returned, plus 1
 ResultFacet[] facets
          Faceted results grouped by field value (if specified in query)
 boolean scoresNormalized
          Whether document scores were normalized so that highest ranking doc has score 100.
 int startDoc
          Ordinal rank of the first document hit returned (0-based)
 SpellingSuggestion[] suggestions
          Spelling suggestions for query terms (if spellcheck specified)
 Set textTerms
          A set that can be used to check whether a given term is present in the original query that produced this hit.
 int totalDocs
          Total number of documents matched by the query (possibly many more than are returned in this particular request.)
 
Constructor Summary
QueryResult()
           
 
Method Summary
 Source hitsToSource(String mainTagName, String extraStuff)
          Makes an XML document out of the list of document hits, and returns a Source object that represents it.
 String hitsToString(String mainTagName, String extraStuff)
          Makes an XML document out of the list of document hits, and returns a String object that represents it.
private  void structureDocHits(DocHit[] docHits, int startDoc, StringBuffer buf)
          Does the work of turning DocHits into XML.
private  void structureExplanation(Explanation exp, StringBuffer buf)
          Does the work of turning a score explanation into XML.
private  void structureGroup(ResultGroup group, StringBuffer buf)
          Does the work of turning faceted groups into XML.
private  void structureSuggestions(StringBuffer buf)
          Does the work of translating spelling suggestions into XML.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

public QueryContext context
Context of the query (including stop word list, and maps for plurals and accents). CrossQuery doesn't use the context, but dynaXML does.


textTerms

public Set textTerms
A set that can be used to check whether a given term is present in the original query that produced this hit. Only applies to the "text" field (i.e. the full text of the document.) CrossQuery doesn't use the text term set, but dynaXML does.


totalDocs

public int totalDocs
Total number of documents matched by the query (possibly many more than are returned in this particular request.)


startDoc

public int startDoc
Ordinal rank of the first document hit returned (0-based)


endDoc

public int endDoc
Oridinal rank of the last document hit returned, plus 1


scoresNormalized

public boolean scoresNormalized
Whether document scores were normalized so that highest ranking doc has score 100.


docHits

public DocHit[] docHits
One hit per document


facets

public ResultFacet[] facets
Faceted results grouped by field value (if specified in query)


suggestions

public SpellingSuggestion[] suggestions
Spelling suggestions for query terms (if spellcheck specified)


decFormat

private DecimalFormat decFormat
Formatter for non-normalized scores

Constructor Detail

QueryResult

public QueryResult()
Method Detail

hitsToSource

public Source hitsToSource(String mainTagName,
                           String extraStuff)
Makes an XML document out of the list of document hits, and returns a Source object that represents it.

Parameters:
mainTagName - Name of the top-level tag to generate (e.g. "crossQueryResult", etc.)
extraStuff - Additional XML to insert into the query result document. Typically includes <parameters> block and <query> block.
Returns:
XML Source containing all the hits and snippets.

hitsToString

public String hitsToString(String mainTagName,
                           String extraStuff)
Makes an XML document out of the list of document hits, and returns a String object that represents it.

Parameters:
mainTagName - Name of the top-level tag to generate (e.g. "crossQueryResult", etc.)
extraStuff - Additional XML to insert into the query result document. Typically includes <parameters> block and <query> block.
Returns:
XML string containing all the hits and snippets.

structureGroup

private void structureGroup(ResultGroup group,
                            StringBuffer buf)
Does the work of turning faceted groups into XML.

Parameters:
group - The group to work on
buf - Buffer to add XML to

structureDocHits

private void structureDocHits(DocHit[] docHits,
                              int startDoc,
                              StringBuffer buf)
Does the work of turning DocHits into XML.

Parameters:
docHits - Array of DocHits to structure
buf - Buffer to add the XML to

structureExplanation

private void structureExplanation(Explanation exp,
                                  StringBuffer buf)
Does the work of turning a score explanation into XML.


structureSuggestions

private void structureSuggestions(StringBuffer buf)
Does the work of translating spelling suggestions into XML.