Class PatternReplaceCharFilter

All Implemented Interfaces:
Closeable, AutoCloseable, 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
  • Field Details

    • pattern

      private final Pattern pattern
    • replacement

      private final String replacement
    • transformedInput

      private Reader transformedInput
  • Constructor Details

    • PatternReplaceCharFilter

      public PatternReplaceCharFilter(Pattern pattern, String replacement, Reader in)
  • Method Details