public class QueryScorer extends java.lang.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.Constructor and Description |
---|
QueryScorer(Query query) |
QueryScorer(Query query,
IndexReader reader,
java.lang.String fieldName) |
QueryScorer(Query query,
java.lang.String fieldName) |
QueryScorer(WeightedTerm[] weightedTerms) |
Modifier and Type | Method and Description |
---|---|
void |
allFragmentsProcessed() |
float |
getFragmentScore()
Called when the highlighter has no more tokens for the current fragment - the scorer returns
the weighting it has derived for the most recent fragment, typically based on the tokens
passed to getTokenScore().
|
float |
getMaxTermWeight() |
float |
getTokenScore(Token token)
Called for each token in the current fragment
|
void |
startFragment(TextFragment newFragment)
called when a new fragment is started for consideration
|
public QueryScorer(Query query)
query
- a Lucene query (ideally rewritten using query.rewrite
before being passed to this class and the searcher)public QueryScorer(Query query, java.lang.String fieldName)
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 termspublic QueryScorer(Query query, IndexReader reader, java.lang.String fieldName)
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 intensityfieldName
- the field on which Inverse Document Frequency (IDF) calculations are basedpublic QueryScorer(WeightedTerm[] weightedTerms)
public void startFragment(TextFragment newFragment)
Scorer
startFragment
in interface Scorer
public float getTokenScore(Token token)
Scorer
getTokenScore
in interface Scorer
token
- The token to be scoredpublic float getFragmentScore()
Scorer
getFragmentScore
in interface Scorer
public void allFragmentsProcessed()
public float getMaxTermWeight()
Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.