public class SpanScorer extends Object implements Scorer
Scorer implementation which scores text fragments by the number of
unique query terms found. This class converts appropriate Querys to
SpanQuerys and attempts to score only those terms that participated in
generating the 'hit' on the document.| Constructor and Description |
|---|
SpanScorer(Query query,
String field,
CachingTokenFilter cachingTokenFilter) |
SpanScorer(Query query,
String field,
CachingTokenFilter cachingTokenFilter,
IndexReader reader) |
SpanScorer(Query query,
String field,
CachingTokenFilter cachingTokenFilter,
IndexReader reader,
String defaultField)
As above, but with ability to pass in an IndexReader
|
SpanScorer(Query query,
String field,
CachingTokenFilter cachingTokenFilter,
String defaultField) |
SpanScorer(WeightedSpanTerm[] weightedTerms) |
| Modifier and Type | Method and Description |
|---|---|
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
|
WeightedSpanTerm |
getWeightedSpanTerm(String token)
Retrieve the WeightedSpanTerm for the specified token.
|
static boolean |
isHighlightCnstScrRngQuery() |
void |
reset()
If you call Highlighter#getBestFragment() more than once you must reset
the SpanScorer between each call.
|
static void |
setHighlightCnstScrRngQuery(boolean highlight)
Turns highlighting of ConstantScoreRangeQuery on/off.
|
void |
startFragment(TextFragment newFragment)
called when a new fragment is started for consideration
|
public SpanScorer(Query query, String field, CachingTokenFilter cachingTokenFilter) throws IOException
query - Query to use for highlightingfield - Field to highlight - pass null to ignore fieldstokenStream - of source text to be highlightedIOExceptionpublic SpanScorer(Query query, String field, CachingTokenFilter cachingTokenFilter, IndexReader reader) throws IOException
query - Query to use for highlightingfield - Field to highlight - pass null to ignore fieldstokenStream - of source text to be highlightedreader - IOExceptionpublic SpanScorer(Query query, String field, CachingTokenFilter cachingTokenFilter, IndexReader reader, String defaultField) throws IOException
IOExceptionpublic SpanScorer(Query query, String field, CachingTokenFilter cachingTokenFilter, String defaultField) throws IOException
defaultField - - The default field for queries with the field name unspecifiedIOExceptionpublic SpanScorer(WeightedSpanTerm[] weightedTerms)
weightedTerms - public float getFragmentScore()
ScorergetFragmentScore in interface Scorerpublic float getMaxTermWeight()
public float getTokenScore(Token token)
ScorergetTokenScore in interface Scorertoken - The token to be scoredpublic WeightedSpanTerm getWeightedSpanTerm(String token)
token - public static boolean isHighlightCnstScrRngQuery()
public void reset()
public static void setHighlightCnstScrRngQuery(boolean highlight)
highlightCnstScrRngQuery - public void startFragment(TextFragment newFragment)
ScorerstartFragment in interface ScorerCopyright © 2000-2013 Apache Software Foundation. All Rights Reserved.