|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.search.highlight.QueryScorer
public class QueryScorer
Scorer
implementation which scores text fragments by the number of
unique query terms found. This class converts appropriate Query
s to
SpanQuery
s and attempts to score only those terms that participated in
generating the 'hit' on the document.
Constructor Summary | |
---|---|
QueryScorer(Query query)
|
|
QueryScorer(Query query,
IndexReader reader,
String field)
|
|
QueryScorer(Query query,
IndexReader reader,
String field,
String defaultField)
|
|
QueryScorer(Query query,
String field)
|
|
QueryScorer(Query query,
String field,
String defaultField)
|
|
QueryScorer(WeightedSpanTerm[] weightedTerms)
|
Method Summary | |
---|---|
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 results of Scorer.getTokenScore() . |
float |
getMaxTermWeight()
|
float |
getTokenScore()
Called for each token in the current fragment. |
WeightedSpanTerm |
getWeightedSpanTerm(String token)
Retrieve the WeightedSpanTerm for the specified token. |
TokenStream |
init(TokenStream tokenStream)
Called to init the Scorer with a TokenStream . |
boolean |
isExpandMultiTermQuery()
|
void |
setExpandMultiTermQuery(boolean expandMultiTermQuery)
Controls whether or not multi-term queries are expanded against a MemoryIndex IndexReader . |
void |
setMaxDocCharsToAnalyze(int maxDocCharsToAnalyze)
|
void |
setWrapIfNotCachingTokenFilter(boolean wrap)
By default, TokenStream s that are not of the type
CachingTokenFilter are wrapped in a CachingTokenFilter to
ensure an efficient reset - if you are already using a different caching
TokenStream impl and you don't want it to be wrapped, set this to
false. |
void |
startFragment(TextFragment newFragment)
Called when a new fragment is started for consideration. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public QueryScorer(Query query)
query
- Query to use for highlightingpublic QueryScorer(Query query, String field)
query
- Query to use for highlightingfield
- Field to highlight - pass null to ignore fieldspublic QueryScorer(Query query, IndexReader reader, String field)
query
- Query to use for highlightingfield
- Field to highlight - pass null to ignore fieldsreader
- IndexReader
to use for quasi tf/idf scoringpublic QueryScorer(Query query, IndexReader reader, String field, String defaultField)
query
- to use for highlightingreader
- IndexReader
to use for quasi tf/idf scoringfield
- to highlight - pass null to ignore fieldsdefaultField
- public QueryScorer(Query query, String field, String defaultField)
defaultField
- - The default field for queries with the field name unspecifiedpublic QueryScorer(WeightedSpanTerm[] weightedTerms)
weightedTerms
- an array of pre-created WeightedSpanTerm
sMethod Detail |
---|
public float getFragmentScore()
Scorer
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 results of Scorer.getTokenScore()
.
getFragmentScore
in interface Scorer
public float getMaxTermWeight()
public float getTokenScore()
Scorer
Highlighter
will
increment the TokenStream
passed to init on every call.
getTokenScore
in interface Scorer
Highlighter
class to influence the
mark-up of the text (this return value is NOT used to score the
fragment)public TokenStream init(TokenStream tokenStream) throws IOException
Scorer
TokenStream
. You can grab references to
the attributes you are interested in here and access them from Scorer.getTokenScore()
.
init
in interface Scorer
tokenStream
- the TokenStream
that will be scored.
TokenStream
that the Highlighter should continue using (eg
if you read the tokenSream in this method) or null to continue
using the same TokenStream
that was passed in.
IOException
public WeightedSpanTerm getWeightedSpanTerm(String token)
WeightedSpanTerm
for the specified token. Useful for passing
Span information to a Fragmenter
.
token
- to get WeightedSpanTerm
for
public void startFragment(TextFragment newFragment)
Scorer
startFragment
in interface Scorer
newFragment
- the fragment that will be scored nextpublic boolean isExpandMultiTermQuery()
public void setExpandMultiTermQuery(boolean expandMultiTermQuery)
MemoryIndex
IndexReader
.
expandMultiTermQuery
- true if multi-term queries should be expandedpublic void setWrapIfNotCachingTokenFilter(boolean wrap)
TokenStream
s that are not of the type
CachingTokenFilter
are wrapped in a CachingTokenFilter
to
ensure an efficient reset - if you are already using a different caching
TokenStream
impl and you don't want it to be wrapped, set this to
false.
wrap
- public void setMaxDocCharsToAnalyze(int maxDocCharsToAnalyze)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |