org.apache.solr.analysis
Class PatternReplaceCharFilter
java.lang.Object
java.io.Reader
org.apache.lucene.analysis.CharStream
org.apache.lucene.analysis.CharFilter
org.apache.lucene.analysis.BaseCharFilter
org.apache.solr.analysis.PatternReplaceCharFilter
- All Implemented Interfaces:
- Closeable, 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"
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
- Version:
- $Id: PatternReplaceCharFilter.java 1294149 2012-02-27 13:29:48Z dweiss $
Method Summary |
protected int |
correct(int currentOff)
|
int |
read(char[] cbuf,
int off,
int len)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEFAULT_MAX_BLOCK_CHARS
@Deprecated
public static final int DEFAULT_MAX_BLOCK_CHARS
- Deprecated.
- See Also:
- Constant Field Values
PatternReplaceCharFilter
public PatternReplaceCharFilter(Pattern pattern,
String replacement,
CharStream in)
PatternReplaceCharFilter
@Deprecated
public PatternReplaceCharFilter(Pattern pattern,
String replacement,
int maxBlockChars,
String blockDelimiter,
CharStream in)
- Deprecated.
read
public int read(char[] cbuf,
int off,
int len)
throws IOException
- Overrides:
read
in class CharFilter
- Throws:
IOException
correct
protected int correct(int currentOff)
- Overrides:
correct
in class BaseCharFilter