Class WeightedSpanTermExtractor
- java.lang.Object
-
- org.apache.lucene.search.highlight.WeightedSpanTermExtractor
-
public class WeightedSpanTermExtractor extends Object
Class used to extractWeightedSpanTerms from aQuerybased on whetherTerms from theQueryare contained in a suppliedTokenStream.
-
-
Constructor Summary
Constructors Constructor Description WeightedSpanTermExtractor()WeightedSpanTermExtractor(String defaultField)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleangetExpandMultiTermQuery()TokenStreamgetTokenStream()Map<String,WeightedSpanTerm>getWeightedSpanTerms(Query query, TokenStream tokenStream)Creates a Map ofWeightedSpanTermsfrom the givenQueryandTokenStream.Map<String,WeightedSpanTerm>getWeightedSpanTerms(Query query, TokenStream tokenStream, String fieldName)Creates a Map ofWeightedSpanTermsfrom the givenQueryandTokenStream.Map<String,WeightedSpanTerm>getWeightedSpanTermsWithScores(Query query, TokenStream tokenStream, String fieldName, IndexReader reader)Creates a Map ofWeightedSpanTermsfrom the givenQueryandTokenStream.booleanisCachedTokenStream()voidsetExpandMultiTermQuery(boolean expandMultiTermQuery)voidsetWrapIfNotCachingTokenFilter(boolean wrap)By default,TokenStreams that are not of the typeCachingTokenFilterare wrapped in aCachingTokenFilterto ensure an efficient reset - if you are already using a different cachingTokenStreamimpl and you don't want it to be wrapped, set this to false.
-
-
-
Constructor Detail
-
WeightedSpanTermExtractor
public WeightedSpanTermExtractor()
-
WeightedSpanTermExtractor
public WeightedSpanTermExtractor(String defaultField)
-
-
Method Detail
-
getWeightedSpanTerms
public Map<String,WeightedSpanTerm> getWeightedSpanTerms(Query query, TokenStream tokenStream) throws IOException
Creates a Map ofWeightedSpanTermsfrom the givenQueryandTokenStream.- Parameters:
query- that caused hittokenStream- of text to be highlighted- Returns:
- Map containing WeightedSpanTerms
- Throws:
IOException- If there is a low-level I/O error
-
getWeightedSpanTerms
public Map<String,WeightedSpanTerm> getWeightedSpanTerms(Query query, TokenStream tokenStream, String fieldName) throws IOException
Creates a Map ofWeightedSpanTermsfrom the givenQueryandTokenStream.- Parameters:
query- that caused hittokenStream- of text to be highlightedfieldName- restricts Term's used based on field name- Returns:
- Map containing WeightedSpanTerms
- Throws:
IOException- If there is a low-level I/O error
-
getWeightedSpanTermsWithScores
public Map<String,WeightedSpanTerm> getWeightedSpanTermsWithScores(Query query, TokenStream tokenStream, String fieldName, IndexReader reader) throws IOException
Creates a Map ofWeightedSpanTermsfrom the givenQueryandTokenStream. Uses a suppliedIndexReaderto 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:
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,TokenStreams that are not of the typeCachingTokenFilterare wrapped in aCachingTokenFilterto ensure an efficient reset - if you are already using a different cachingTokenStreamimpl and you don't want it to be wrapped, set this to false.
-
-