Class WeightedSpanTermExtractor
- java.lang.Object
-
- org.apache.lucene.search.highlight.WeightedSpanTermExtractor
-
public class WeightedSpanTermExtractor extends java.lang.Object
Class used to extractWeightedSpanTerm
s from aQuery
based on whetherTerm
s from theQuery
are contained in a suppliedTokenStream
.
-
-
Constructor Summary
Constructors Constructor Description WeightedSpanTermExtractor()
WeightedSpanTermExtractor(java.lang.String defaultField)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
getExpandMultiTermQuery()
TokenStream
getTokenStream()
java.util.Map<java.lang.String,WeightedSpanTerm>
getWeightedSpanTerms(Query query, TokenStream tokenStream)
Creates a Map ofWeightedSpanTerms
from the givenQuery
andTokenStream
.java.util.Map<java.lang.String,WeightedSpanTerm>
getWeightedSpanTerms(Query query, TokenStream tokenStream, java.lang.String fieldName)
Creates a Map ofWeightedSpanTerms
from the givenQuery
andTokenStream
.java.util.Map<java.lang.String,WeightedSpanTerm>
getWeightedSpanTermsWithScores(Query query, TokenStream tokenStream, java.lang.String fieldName, IndexReader reader)
Creates a Map ofWeightedSpanTerms
from the givenQuery
andTokenStream
.boolean
isCachedTokenStream()
void
setExpandMultiTermQuery(boolean expandMultiTermQuery)
void
setWrapIfNotCachingTokenFilter(boolean wrap)
By default,TokenStream
s that are not of the typeCachingTokenFilter
are wrapped in aCachingTokenFilter
to ensure an efficient reset - if you are already using a different cachingTokenStream
impl and you don't want it to be wrapped, set this to false.
-
-
-
Method Detail
-
getWeightedSpanTerms
public java.util.Map<java.lang.String,WeightedSpanTerm> getWeightedSpanTerms(Query query, TokenStream tokenStream) throws java.io.IOException
Creates a Map ofWeightedSpanTerms
from the givenQuery
andTokenStream
.- Parameters:
query
- that caused hittokenStream
- of text to be highlighted- Returns:
- Map containing WeightedSpanTerms
- Throws:
java.io.IOException
- If there is a low-level I/O error
-
getWeightedSpanTerms
public java.util.Map<java.lang.String,WeightedSpanTerm> getWeightedSpanTerms(Query query, TokenStream tokenStream, java.lang.String fieldName) throws java.io.IOException
Creates a Map ofWeightedSpanTerms
from the givenQuery
andTokenStream
.- Parameters:
query
- that caused hittokenStream
- of text to be highlightedfieldName
- restricts Term's used based on field name- Returns:
- Map containing WeightedSpanTerms
- Throws:
java.io.IOException
- If there is a low-level I/O error
-
getWeightedSpanTermsWithScores
public java.util.Map<java.lang.String,WeightedSpanTerm> getWeightedSpanTermsWithScores(Query query, TokenStream tokenStream, java.lang.String fieldName, IndexReader reader) throws java.io.IOException
Creates a Map ofWeightedSpanTerms
from the givenQuery
andTokenStream
. Uses a suppliedIndexReader
to properly weight terms (for gradient highlighting).- Parameters:
query
- that caused hittokenStream
- of text to be highlightedfieldName
- restricts Term's used based on field namereader
- to use for scoring- Returns:
- Map of WeightedSpanTerms with quasi tf/idf scores
- Throws:
java.io.IOException
- If there is a low-level I/O error
-
getExpandMultiTermQuery
public boolean getExpandMultiTermQuery()
-
setExpandMultiTermQuery
public void setExpandMultiTermQuery(boolean expandMultiTermQuery)
-
isCachedTokenStream
public boolean isCachedTokenStream()
-
getTokenStream
public TokenStream getTokenStream()
-
setWrapIfNotCachingTokenFilter
public void setWrapIfNotCachingTokenFilter(boolean wrap)
By default,TokenStream
s that are not of the typeCachingTokenFilter
are wrapped in aCachingTokenFilter
to ensure an efficient reset - if you are already using a different cachingTokenStream
impl and you don't want it to be wrapped, set this to false.
-
-