Share via


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, 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.

Boolean getExpand()

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.

String getOdataType()

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

List<String> getSynonyms()

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

Boolean isCaseIgnored()

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

SynonymTokenFilter setCaseIgnored(Boolean caseIgnored)

Set the caseIgnored 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.

JsonWriter toJson(JsonWriter jsonWriter)

Methods inherited from TokenFilter

Methods inherited from java.lang.Object

Constructor Details

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.

getExpand

public Boolean getExpand()

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.

getOdataType

public String getOdataType()

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

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.

isCaseIgnored

public Boolean isCaseIgnored()

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

Returns:

the caseIgnored value.

setCaseIgnored

public SynonymTokenFilter setCaseIgnored(Boolean caseIgnored)

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

Parameters:

caseIgnored - the caseIgnored value to set.

Returns:

the SynonymTokenFilter object itself.

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.

toJson

public JsonWriter toJson(JsonWriter jsonWriter)

Overrides:

SynonymTokenFilter.toJson(JsonWriter jsonWriter)

Parameters:

jsonWriter

Throws:

Applies to