public class ReversedWildcardFilterFactory extends BaseTokenFilterFactory
ReversedWildcardFilter
-s. When this factory is
added to an analysis chain, it will be used both for filtering the
tokens during indexing, and to determine the query processing of
this field during search.
This class supports the following init arguments:
withOriginal
- if true, then produce both original and reversed tokens at
the same positions. If false, then produce only reversed tokens.maxPosAsterisk
- maximum position (1-based) of the asterisk wildcard
('*') that triggers the reversal of query term. Asterisk that occurs at
positions higher than this value will not cause the reversal of query term.
Defaults to 2, meaning that asterisks on positions 1 and 2 will cause
a reversal.maxPosQuestion
- maximum position (1-based) of the question
mark wildcard ('?') that triggers the reversal of query term. Defaults to 1.
Set this to 0, and maxPosAsterisk
to 1 to reverse only
pure suffix queries (i.e. ones with a single leading asterisk).maxFractionAsterisk
- additional parameter that
triggers the reversal if asterisk ('*') position is less than this
fraction of the query token length. Defaults to 0.0f (disabled).minTrailing
- minimum number of trailing characters in query
token after the last wildcard character. For good performance this should be
set to a value larger than 1. Defaults to 2.
<fieldType name="text_rvswc" class="solr.TextField" positionIncrementGap="100"> <analyzer type="index"> <tokenizer class="solr.WhitespaceTokenizerFactory"/> <filter class="solr.ReversedWildcardFilterFactory" withOriginal="true" maxPosAsterisk="2" maxPosQuestion="1" minTrailing="2" maxFractionAsterisk="0"/> </analyzer> <analyzer type="query"> <tokenizer class="solr.WhitespaceTokenizerFactory"/> </analyzer> </fieldType>
Modifier and Type | Field and Description |
---|---|
private char |
markerChar |
private float |
maxFractionAsterisk |
private int |
maxPosAsterisk |
private int |
maxPosQuestion |
private int |
minTrailing |
private boolean |
withOriginal |
log
args, luceneMatchVersion
Constructor and Description |
---|
ReversedWildcardFilterFactory() |
Modifier and Type | Method and Description |
---|---|
org.apache.lucene.analysis.TokenStream |
create(org.apache.lucene.analysis.TokenStream input)
Transform the specified input TokenStream
|
protected float |
getFloat(java.lang.String name,
float defValue) |
char |
getMarkerChar() |
void |
init(java.util.Map<java.lang.String,java.lang.String> args)
init will be called just once, immediately after creation. |
boolean |
shouldReverse(java.lang.String token)
This method encapsulates the logic that determines whether
a query token should be reversed in order to use the
reversed terms in the index.
|
assureMatchVersion, getArgs, getBoolean, getBoolean, getInt, getInt, getInt, getSnowballWordSet, getWordSet, warnDeprecated
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getArgs
private char markerChar
private boolean withOriginal
private int maxPosAsterisk
private int maxPosQuestion
private int minTrailing
private float maxFractionAsterisk
public void init(java.util.Map<java.lang.String,java.lang.String> args)
TokenFilterFactory
init
will be called just once, immediately after creation.
The args are user-level initialization parameters that may be specified when declaring the factory in the schema.xml
init
in interface TokenFilterFactory
init
in class BaseTokenStreamFactory
public org.apache.lucene.analysis.TokenStream create(org.apache.lucene.analysis.TokenStream input)
TokenFilterFactory
public boolean shouldReverse(java.lang.String token)
token
- input token.public char getMarkerChar()
protected float getFloat(java.lang.String name, float defValue)