Class PatternReplaceCharFilter
java.lang.Object
java.io.Reader
org.apache.lucene.analysis.CharFilter
org.apache.lucene.analysis.charfilter.BaseCharFilter
org.apache.lucene.analysis.pattern.PatternReplaceCharFilter
- All Implemented Interfaces:
Closeable,AutoCloseable,Readable
CharFilter that uses a regular expression for the target of replace string. The pattern match
will be done in each "block" in char stream.
ex1) source="aa bb aa bb", pattern="(aa)\\s+(bb)" replacement="$1#$2"
output="aa#bb aa#bb" NOTE: If you produce a phrase that has different length to source
string and the field is used for highlighting for a term of the phrase, you will face a trouble.
ex2) source="aa123bb", pattern="(aa)\\d+(bb)" replacement="$1 $2"
output="aa bb"
and you want to search bb and highlight it, you will get
highlight snippet="aa1<em>23bb</em>"
- Since:
- Solr 1.5
-
Field Summary
FieldsFields inherited from class org.apache.lucene.analysis.CharFilter
input -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intcorrect(int currentOff) Retrieve the corrected offset.private voidfill()(package private) CharSequenceprocessPattern(CharSequence input) Replace pattern in input and mark correction offsets.intread()intread(char[] cbuf, int off, int len) Methods inherited from class org.apache.lucene.analysis.charfilter.BaseCharFilter
addOffCorrectMap, getLastCumulativeDiffMethods inherited from class org.apache.lucene.analysis.CharFilter
close, correctOffsetMethods inherited from class java.io.Reader
mark, markSupported, nullReader, read, read, ready, reset, skip, transferTo
-
Field Details
-
pattern
-
replacement
-
transformedInput
-
-
Constructor Details
-
PatternReplaceCharFilter
-
-
Method Details
-
read
- Specified by:
readin classReader- Throws:
IOException
-
fill
- Throws:
IOException
-
read
- Overrides:
readin classReader- Throws:
IOException
-
correct
protected int correct(int currentOff) Description copied from class:BaseCharFilterRetrieve the corrected offset.- Overrides:
correctin classBaseCharFilter- Parameters:
currentOff- current offset- Returns:
- corrected offset
-
processPattern
Replace pattern in input and mark correction offsets.
-