org.apache.lucene.search.highlight

Class QueryScorer

Implemented Interfaces:
Scorer

public class QueryScorer
extends Object
implements Scorer

Scorer implementation which scores text fragments by the number of unique query terms found. This class uses the QueryTermExtractor class to process determine the query terms and their boosts to be used.
Author:
mark@searcharea.co.uk

Constructor Summary

QueryScorer(Query query)
QueryScorer(Query query, String fieldName)
QueryScorer(Query query, IndexReader reader, String fieldName)
QueryScorer(WeightedTerm[] weightedTerms)

Method Summary

void
allFragmentsProcessed()
float
getFragmentScore()
float
getMaxTermWeight()
float
getTokenScore(Token token)
void
startFragment(TextFragment newFragment)

Constructor Details

QueryScorer

public QueryScorer(Query query)
Parameters:
query - a Lucene query (ideally rewritten using query.rewrite before being passed to this class and the searcher)

QueryScorer

public QueryScorer(Query query,
                   String fieldName)
Parameters:
query - a Lucene query (ideally rewritten using query.rewrite before being passed to this class and the searcher)
fieldName - the Field name which is used to match Query terms

QueryScorer

public QueryScorer(Query query,
                   IndexReader reader,
                   String fieldName)
Parameters:
query - a Lucene query (ideally rewritten using query.rewrite before being passed to this class and the searcher)
reader - used to compute IDF which can be used to a) score selected fragments better b) use graded highlights eg set font color intensity
fieldName - the field on which Inverse Document Frequency (IDF) calculations are based

QueryScorer

public QueryScorer(WeightedTerm[] weightedTerms)

Method Details

allFragmentsProcessed

public void allFragmentsProcessed()

getFragmentScore

public float getFragmentScore()
Specified by:
getFragmentScore in interface Scorer

getMaxTermWeight

public float getMaxTermWeight()
Returns:
The highest weighted term (useful for passing to GradientFormatter to set top end of coloring scale.

getTokenScore

public float getTokenScore(Token token)
Specified by:
getTokenScore in interface Scorer

startFragment

public void startFragment(TextFragment newFragment)
Specified by:
startFragment in interface Scorer

Copyright © 2000-2006 Apache Software Foundation. All Rights Reserved.