org.apache.solr.analysis
Class PatternReplaceCharFilter

java.lang.Object
  extended by java.io.Reader
      extended by org.apache.lucene.analysis.CharStream
          extended by org.apache.lucene.analysis.CharFilter
              extended by org.apache.lucene.analysis.BaseCharFilter
                  extended by org.apache.solr.analysis.PatternReplaceCharFilter
All Implemented Interfaces:
Closeable, Readable

public class PatternReplaceCharFilter
extends org.apache.lucene.analysis.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 1065312 2011-01-30 16:08:25Z rmuir $

Field Summary
static int DEFAULT_MAX_BLOCK_CHARS
           
 
Fields inherited from class org.apache.lucene.analysis.CharFilter
input
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
PatternReplaceCharFilter(Pattern pattern, String replacement, org.apache.lucene.analysis.CharStream in)
           
PatternReplaceCharFilter(Pattern pattern, String replacement, int maxBlockChars, org.apache.lucene.analysis.CharStream in)
           
PatternReplaceCharFilter(Pattern pattern, String replacement, int maxBlockChars, String blockDelimiters, org.apache.lucene.analysis.CharStream in)
           
PatternReplaceCharFilter(Pattern pattern, String replacement, String blockDelimiters, org.apache.lucene.analysis.CharStream in)
           
 
Method Summary
 int read()
           
 int read(char[] cbuf, int off, int len)
           
 
Methods inherited from class org.apache.lucene.analysis.BaseCharFilter
addOffCorrectMap, correct, getLastCumulativeDiff
 
Methods inherited from class org.apache.lucene.analysis.CharFilter
close, correctOffset, mark, markSupported, reset
 
Methods inherited from class java.io.Reader
read, read, ready, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_BLOCK_CHARS

public static final int DEFAULT_MAX_BLOCK_CHARS
See Also:
Constant Field Values
Constructor Detail

PatternReplaceCharFilter

public PatternReplaceCharFilter(Pattern pattern,
                                String replacement,
                                org.apache.lucene.analysis.CharStream in)

PatternReplaceCharFilter

public PatternReplaceCharFilter(Pattern pattern,
                                String replacement,
                                int maxBlockChars,
                                org.apache.lucene.analysis.CharStream in)

PatternReplaceCharFilter

public PatternReplaceCharFilter(Pattern pattern,
                                String replacement,
                                String blockDelimiters,
                                org.apache.lucene.analysis.CharStream in)

PatternReplaceCharFilter

public PatternReplaceCharFilter(Pattern pattern,
                                String replacement,
                                int maxBlockChars,
                                String blockDelimiters,
                                org.apache.lucene.analysis.CharStream in)
Method Detail

read

public int read()
         throws IOException
Overrides:
read in class Reader
Throws:
IOException

read

public int read(char[] cbuf,
                int off,
                int len)
         throws IOException
Overrides:
read in class org.apache.lucene.analysis.CharFilter
Throws:
IOException


Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.