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:
java.io.Closeable,java.lang.AutoCloseable,java.lang.Readable
public class PatternReplaceCharFilter extends BaseCharFilter
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"
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.
output="aa#bb aa#bb"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
Fields Modifier and Type Field Description private java.util.regex.Patternpatternprivate java.lang.Stringreplacementprivate java.io.ReadertransformedInput-
Fields inherited from class org.apache.lucene.analysis.CharFilter
input
-
-
Constructor Summary
Constructors Constructor Description PatternReplaceCharFilter(java.util.regex.Pattern pattern, java.lang.String replacement, java.io.Reader in)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected intcorrect(int currentOff)Retrieve the corrected offset.private voidfill()(package private) java.lang.CharSequenceprocessPattern(java.lang.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, getLastCumulativeDiff
-
Methods inherited from class org.apache.lucene.analysis.CharFilter
close, correctOffset
-
-
-
-
Method Detail
-
read
public int read(char[] cbuf, int off, int len) throws java.io.IOException- Specified by:
readin classjava.io.Reader- Throws:
java.io.IOException
-
fill
private void fill() throws java.io.IOException- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException- Overrides:
readin classjava.io.Reader- Throws:
java.io.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
java.lang.CharSequence processPattern(java.lang.CharSequence input)
Replace pattern in input and mark correction offsets.
-
-