Skip to main content
Version: 2025.0

IndexTerm

A default term for the index search representing a single search condition. e.g. "firstname_value:lisa~^1.2" As all term typs this type supports the standard functions for setting the field name (entity and index) and the search weighting (boost). The value can not be null. Fuzzy search: This term type provides the option to perform a fuzzy search (~) by setting a factor using term.setFuzzySearchFactor(pInt). Fuzzy searches discover terms that are similar to a specified term without necessarily being an exact match. The comparison is carried out at the character level and searches for values ??that match to the expression with the specified maximum of different characters. Differences in length count as change. The expression will always match exact matches. The maximum supported amount of differences is 2. Examples: The expression roam~ ( max 2 differences ) will match terms like roams, foam and foams. The expression roam~1 will match terms like roams and foam - but not foams since it has an edit distance of "2". NOTE: Do not add unescaped quoted values ( phrases ), multiple values/words separated by whitespaces (phrases or groups), or values with unescaped wildcards (* and ?). This will result in an invalid configuration that can not be searched or returns unexpected results. It will always break the fuzzy search which is only supported by simple terms without wildcards. The term object must be added to an IndexPatternConfig or a group term in order to create an index search pattern.

Methods

getBoost

getBoost(): number

Returns the boost factor for this therm. The index search provides the relevance level of matching documents based on the terms found. Boosting allows you to control the relevance of a result document by boosting its term. The higher the boost factor, the more relevant the term will be. The default boost factor for each term is 1.0. The boost factor must always be a positiv value grater the 0.0.

Returns

number

The boost factor of this term.


getEntityField

getEntityField(): string

Returns

string

The defined entity field in which to search for the value. null if not set.


getFuzzySearchFactor

getFuzzySearchFactor(): number

Returns the maximum number of changes that are made to the search term during the fuzzy search. If not set, -1 is returned.

Returns

number

the fuzzy search factor of this term.


getIndexField

getIndexField(): string

Returns

string

The defined index field in which to search for the value. null if not set.


getValue

getValue(): string

The searched value represented by this term.

Returns

string

The value to be searched for as a string.


setBoost

setBoost(pBoost): IndexTerm

Specifies the boost factor for this therm. The index search provides the relevance level of matching documents based on the terms found. Boosting allows you to control the relevance of a result document by boosting its term. The higher the boost factor, the more relevant the term will be. The implicit default boost factor for each term is 1.0. To increase the relevance specify a value greater then 1.0, e.g. 1.5. To decrease the relevance specify a value lower then 1.0, e.g. 0.5. The boost factor must always be a positiv value grater the 0.0.

Parameters

pBoost
number

the boost factor of this term.

Returns

IndexTerm

setEntityField

setEntityField(pEntityField): IndexTerm

Specifies the entity field in whose corresponding index field to search for the value. If not set, the value of the term is searched in all search fields specified in the IndexQuery. The names of the entity field must start with the defining entity, e.g. person_entity.FIRSTNAME. You can specify whether the index field defined for value or displayValue should be used, e.g. person_entity.FIRSTNAME.displayValue. If not specified, the index field defined for value is returned. The index field is looked up when calling searchIndex. The search fails if no index field can be determined for the specified entity field.

Parameters

pEntityField
string | number | boolean

the name of the entity field.

Returns

IndexTerm

setFuzzySearchFactor

setFuzzySearchFactor(pFuzzySearchFactor): IndexTerm

Sets the maximum number of changes that are made to the search term during the fuzzy search. The fuzzy search is only performed if the factor for this term has been explicitly specified. Fuzzy search: This term type provides the option to perform a fuzzy search (~) by setting a factor using term.setFuzzySearchFactor(pInt). Fuzzy searches discover terms that are similar to a specified term without necessarily being an exact match. The comparison is carried out at the character level and searches for values ??that match to the expression with the specified maximum of different characters. Differences in length count as change. The expression will always match exact matches. The maximum supported amount of differences is 2. Examples: The expression roam~ ( max 2 differences ) will match terms like roams, foam and foams. The expression roam~1 will match terms like roams and foam - but not foams since it has an edit distance of "2". Possible values:

  • 0: Uses the maximum of the engine (2) -> test~

  • 1: maximum of one change -> test~1

  • 2: maximum of two changes -> test~2

  • N: maximum 2 changes due to engine limit -> test~

Parameters

pFuzzySearchFactor
number

the fuzzy search factor of this term.

Returns

IndexTerm

setIndexField

setIndexField(pIndexFieldName): IndexTerm

Specifies the index field in which to search for the value. If not set, the value of the term is searched in all search fields specified in the IndexQuery.

Parameters

pIndexFieldName
string | number | boolean

the name of the index field.

Returns

IndexTerm

setValue

setValue(pValue): IndexTerm

Sets the value to search for. The value can not be null.

Parameters

pValue
string | number | boolean

The new value to search for.

Returns

IndexTerm

Example

<code>
import("system.indexsearch");

// This example is meant to show syntax.

// Constructs the term 'field_value:foo^1.3'
var term = indexsearch.createTerm("foo")
.setEntityField("entityName.FIELD.value")
.setBoost(1.3);

// Constructs a fuzzy search term 'bar~' using max differences of 2.
term = indexsearch.createTerm("bar")
.setFuzzySearchFactor(0);

// Constructs a fuzzy search term 'foo:bar~1'
// matching the value 'bar' with 1 difference in the field 'foo'.
term.setIndexField("foo").setFuzzySearchFactor(1);

var patternConf = indexsearch.createPatternConfig().or(term);
</code>