SynonymTokenFilter Class

public final class SynonymTokenFilter
extends TokenFilter

Matches single or multi-word synonyms in a token stream. This token filter is implemented using Apache Lucene.

Constructor Summary

Constructor Description
SynonymTokenFilter(String name, String[] synonyms)

Creates an instance of SynonymTokenFilter class.

SynonymTokenFilter(String name, List<String> synonyms)

Creates an instance of SynonymTokenFilter class.

Method Summary

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

Reads an instance of SynonymTokenFilter from the JsonReader.

String getOdataType()

Get the odataType property: The discriminator for derived types.

List<String> getSynonyms()

Get the synonyms property: A list of synonyms in following one of two formats: 1.

Boolean isExpand()

Get the expand property: A value indicating whether all words in the list of synonyms (if => notation is not used) will map to one another.

Boolean isIgnoreCase()

Get the ignoreCase property: A value indicating whether to case-fold input for matching.

SynonymTokenFilter setExpand(Boolean expand)

Set the expand property: A value indicating whether all words in the list of synonyms (if => notation is not used) will map to one another.

SynonymTokenFilter setIgnoreCase(Boolean ignoreCase)

Set the ignoreCase property: A value indicating whether to case-fold input for matching.

JsonWriter toJson(JsonWriter jsonWriter)

Methods inherited from TokenFilter

Methods inherited from java.lang.Object

Constructor Details

SynonymTokenFilter

public SynonymTokenFilter(String name, String[] synonyms)

Creates an instance of SynonymTokenFilter class.

Parameters:

name - the name value to set.
synonyms - the synonyms value to set.

SynonymTokenFilter

public SynonymTokenFilter(String name, List<String> synonyms)

Creates an instance of SynonymTokenFilter class.

Parameters:

name - the name value to set.
synonyms - the synonyms value to set.

Method Details

fromJson

public static SynonymTokenFilter fromJson(JsonReader jsonReader)

Reads an instance of SynonymTokenFilter from the JsonReader.

Parameters:

jsonReader - The JsonReader being read.

Returns:

An instance of SynonymTokenFilter 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: The discriminator for derived types.

Overrides:

SynonymTokenFilter.getOdataType()

Returns:

the odataType value.

getSynonyms

public List<String> getSynonyms()

Get the synonyms property: A list of synonyms in following one of two formats: 1. incredible, unbelievable, fabulous => amazing - all terms on the left side of => symbol will be replaced with all terms on its right side; 2. incredible, unbelievable, fabulous, amazing - comma separated list of equivalent words. Set the expand option to change how this list is interpreted.

Returns:

the synonyms value.

isExpand

public Boolean isExpand()

Get the expand property: A value indicating whether all words in the list of synonyms (if => notation is not used) will map to one another. If true, all words in the list of synonyms (if => notation is not used) will map to one another. The following list: incredible, unbelievable, fabulous, amazing is equivalent to: incredible, unbelievable, fabulous, amazing => incredible, unbelievable, fabulous, amazing. If false, the following list: incredible, unbelievable, fabulous, amazing will be equivalent to: incredible, unbelievable, fabulous, amazing => incredible. Default is true.

Returns:

the expand value.

isIgnoreCase

public Boolean isIgnoreCase()

Get the ignoreCase property: A value indicating whether to case-fold input for matching. Default is false.

Returns:

the ignoreCase value.

setExpand

public SynonymTokenFilter setExpand(Boolean expand)

Set the expand property: A value indicating whether all words in the list of synonyms (if => notation is not used) will map to one another. If true, all words in the list of synonyms (if => notation is not used) will map to one another. The following list: incredible, unbelievable, fabulous, amazing is equivalent to: incredible, unbelievable, fabulous, amazing => incredible, unbelievable, fabulous, amazing. If false, the following list: incredible, unbelievable, fabulous, amazing will be equivalent to: incredible, unbelievable, fabulous, amazing => incredible. Default is true.

Parameters:

expand - the expand value to set.

Returns:

the SynonymTokenFilter object itself.

setIgnoreCase

public SynonymTokenFilter setIgnoreCase(Boolean ignoreCase)

Set the ignoreCase property: A value indicating whether to case-fold input for matching. Default is false.

Parameters:

ignoreCase - the ignoreCase value to set.

Returns:

the SynonymTokenFilter object itself.

toJson

public JsonWriter toJson(JsonWriter jsonWriter)

Overrides:

SynonymTokenFilter.toJson(JsonWriter jsonWriter)

Parameters:

jsonWriter

Throws:

Applies to