Class 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"
    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
    • Constructor Summary

      Constructors 
      Constructor Description
      PatternReplaceCharFilter​(java.util.regex.Pattern pattern, java.lang.String replacement, int maxBlockChars, java.lang.String blockDelimiter, java.io.Reader in)
      Deprecated.
      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
      int read()  
      int read​(char[] cbuf, int off, int len)  
      • Methods inherited from class java.io.Reader

        mark, markSupported, nullReader, read, read, ready, reset, skip, transferTo
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_MAX_BLOCK_CHARS

        @Deprecated
        public static final int DEFAULT_MAX_BLOCK_CHARS
        Deprecated.
        See Also:
        Constant Field Values
    • Constructor Detail

      • PatternReplaceCharFilter

        public PatternReplaceCharFilter​(java.util.regex.Pattern pattern,
                                        java.lang.String replacement,
                                        java.io.Reader in)
      • PatternReplaceCharFilter

        @Deprecated
        public PatternReplaceCharFilter​(java.util.regex.Pattern pattern,
                                        java.lang.String replacement,
                                        int maxBlockChars,
                                        java.lang.String blockDelimiter,
                                        java.io.Reader in)
        Deprecated.
    • Method Detail

      • read

        public int read​(char[] cbuf,
                        int off,
                        int len)
                 throws java.io.IOException
        Specified by:
        read in class java.io.Reader
        Throws:
        java.io.IOException
      • read

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