Share via


PatternReplaceTokenFilter Class

public final class PatternReplaceTokenFilter
extends TokenFilter

A character filter that replaces characters in the input string. It uses a regular expression to identify character sequences to preserve and a replacement pattern to identify characters to replace. For example, given the input text "aa bb aa bb", pattern "(aa)\s+(bb)", and replacement "$1#$2", the result would be "aa#bb aa#bb". This token filter is implemented using Apache Lucene.

Constructor Summary

Constructor Description
PatternReplaceTokenFilter(String name, String pattern, String replacement)

Creates an instance of PatternReplaceTokenFilter class.

Method Summary

Modifier and Type Method and Description
static PatternReplaceTokenFilter fromJson(JsonReader jsonReader)

Reads an instance of PatternReplaceTokenFilter from the JsonReader.

String getOdataType()

Get the odataType property: A URI fragment specifying the type of token filter.

String getPattern()

Get the pattern property: A regular expression pattern.

String getReplacement()

Get the replacement property: The replacement text.

JsonWriter toJson(JsonWriter jsonWriter)

Methods inherited from TokenFilter

Methods inherited from java.lang.Object

Constructor Details

PatternReplaceTokenFilter

public PatternReplaceTokenFilter(String name, String pattern, String replacement)

Creates an instance of PatternReplaceTokenFilter class.

Parameters:

name - the name value to set.
pattern - the pattern value to set.
replacement - the replacement value to set.

Method Details

fromJson

public static PatternReplaceTokenFilter fromJson(JsonReader jsonReader)

Reads an instance of PatternReplaceTokenFilter from the JsonReader.

Parameters:

jsonReader - The JsonReader being read.

Returns:

An instance of PatternReplaceTokenFilter if the JsonReader was pointing to an instance of it, or null if it was pointing to JSON null.

Throws:

IOException

- If the deserialized JSON object was missing any required properties.

getOdataType

public String getOdataType()

Get the odataType property: A URI fragment specifying the type of token filter.

Overrides:

PatternReplaceTokenFilter.getOdataType()

Returns:

the odataType value.

getPattern

public String getPattern()

Get the pattern property: A regular expression pattern.

Returns:

the pattern value.

getReplacement

public String getReplacement()

Get the replacement property: The replacement text.

Returns:

the replacement value.

toJson

public JsonWriter toJson(JsonWriter jsonWriter)

Overrides:

PatternReplaceTokenFilter.toJson(JsonWriter jsonWriter)

Parameters:

jsonWriter

Throws:

Applies to