Skip to main content
Version: 2026.0

IndexPatternConfig

Configuration object for defining a pattern for the index search. A search pattern can be created with the configuration object without knowing the specific syntax required for the pattern. The individual search terms are defined in the form of term objects, which are then added to the pattern configuration. The configuration is similar to a builder pattern and offers functions to add terms with different operators. The order in which the terms are added indicates the order in the final pattern. NOTE: The order of the terms cannot be changed after they have been added. After configuration the pattern can build by calling the function indexsearch.buildPattern(pPatternConfig) All terms can be created using the corresponding indexsearch.createXXXTerm() functions. Apart from the specific methods of the individual term types, each type supports the standard functions for setting the field name (entity and index) and the search weighting (boost). Available Terms:

  • Simple index term (createTerm): Creates a simple term object for a single value. e.g. Lisa or firstname_value:Lisa

  • Wildcard term (createWildcardTerm): Creates a wildcard term for searching prefixes (foo*), postfixes (*foo) and word parts (*foo*).

  • Phrase term (createPhraseTerm): Creates a phrase that contains a text or sentence in quotation marks. e.g. "Lisa Sommer".

  • Range term (createRangeTerm): Creates a term to find matches within a range of numbers, characters, or words (alphabetically). e.g. [1 TO 2], [f TO *] or [search TO searching]

  • Group term (createGroupTerm): Creates a term that represents a group of terms that belong together. e.g. ( +Lisa +Sommer ) OR l.sommer@domain.local This object is empty after creation () and allows to add terms similar to the pattern configuration. By using a group, it is possible to search for a number of terms in a single index field without specifying each field for each term. e.g lastname_value:( Sommer Admin Leicht )

Methods

and

and(pTerm): IndexPatternConfig

Adds the term to the end of the pattern using the operator AND. If it is the first term of the pattern, it is added with the leading operator +. AND requires that this and the previous term be present for a match.

Parameters

pTerm
IIndexTerm

The term to be appended.

Returns

IndexPatternConfig

asGroupTerm

asGroupTerm(): GroupTerm

Creates a new GroupTerm with the terms of this pattern.

Returns

the current pattern as group term.


isAlwaysUseLeadingOperator

isAlwaysUseLeadingOperator(): boolean

Flag that specifies if the internal PatternBuilder, should only use leading operators (+, -) to create the pattern. The default is true. If set to false, all operators (AND, OR and NOT) are written as defined by the pattern configuration.

Returns

boolean

The specified flag value.


isEmpty

isEmpty(): boolean

Returns

boolean

true if the pattern does not contain any terms.


minus

minus(pTerm): IndexPatternConfig

Adds the term to the end of the pattern using the leading operator -. - prohibits this term. The - operator is functionally similar to the Boolean operator !

Parameters

pTerm
IIndexTerm

The term to be appended.

Returns

IndexPatternConfig

not

not(pTerm): IndexPatternConfig

Adds the term to the end of the pattern using the operator NOT. If it is the first term of the pattern, it is added with the leading operator -. NOT requires this term to be not present.

Parameters

pTerm
IIndexTerm

The term to be appended.

Returns

IndexPatternConfig

or

or(pTerm): IndexPatternConfig

Adds the term to the end of the pattern using the operator OR. If it is the first term of the pattern, it is added without a leading operator. OR requires that either this or the previous term (or both terms) be present for a match.

Parameters

pTerm
IIndexTerm

The term to be appended.

Returns

IndexPatternConfig

plus

plus(pTerm): IndexPatternConfig

Adds the term to the end of the pattern using the leading operator +. + requires this term to be present.

Parameters

pTerm
IIndexTerm

The term to be appended.

Returns

IndexPatternConfig

setAlwaysUseLeadingOperator

setAlwaysUseLeadingOperator(pAlwaysUseLeadingOperator): IndexPatternConfig

Sets the flag for the internal PatternBuilder, whether only leading operators (+, -) should be used to create the pattern. The default is true. If set to false, all operators (AND, OR and NOT) are written as defined by the pattern configuration.

Parameters

pAlwaysUseLeadingOperator
boolean

true if only leading operators should be used.

Returns

IndexPatternConfig

Example

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

// firstname_value:Lisa
var term = indexsearch.createTerm("Lisa")
.setEntityField("Person_entity.FIRSTNAME");

// lastname_value:S*^1.4
var wildcard = indexsearch.createWildcardTerm("S")
.setIndexField("lastname_value")
.setBoost(1.4);
// "foo bar"~2
var phrase = indexsearch.createPhraseTerm("foo bar")
.setProximity(2);

// indexzip_value:[84000 TO 85000]
var range = indexsearch.createRangeTerm("84000", "86000")
.setEntityField("Person_entity.IndexZIP");

// ( +firstname_value:Lisa +lastname_value:S*^1.4 )
var name_group = indexsearch.createGroupTerm()
.plus(term)
.plus(wildcard);

//create the final pattern configuration.
//( +firstname_value:Lisa +lastname_value:S*^1.4 ) -"foo bar"~2 +indexzip_value:[84000 TO 85000]
var patternConf = indexsearch.createPatternConfig()
.or(name_group)
.minus(phrase)
.plus(range);

// build the pattern and returns the result as a string.
var pattern = indexsearch.buildPattern(patternConf);
</code>