Skip to main content
Version: 2026.0

NestedPattern

A IndexTerm object which encapsulates a given pattern and allows it to be used within another pattern.

When added to another builder object as term it will be written as explizit nested pattern using the appropriate field name _query_.

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.


getConstantScore

getConstantScore(): number

Returns the constant score value for this therm.

If set, all matching hits for this term will then always return the same fixed value that is later used to calculate the overall document score.

This is useful when using nested queries, which are mainly used for filtering, in order not to distort the score of the document, or to adjust it only in a limited way.

The value must always be a positiv value grater or equal to 0.0. If set to NULL (default) no constant scoring is used.

Returns

number

the value used as constant score or NULL for none.


getEntityField

getEntityField(): string

Not supported for nested patterns. This is a special case for index terms that does not accept field names. The function will always return NULL.

Returns

string

always NULL.


getIndexField

getIndexField(): string

Not supported for nested patterns. This is a special case for index terms that does not accept field names. The function will always return NULL.

Returns

string

always NULL.


setBoost

setBoost(pBoost): NestedPattern

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

NestedPattern

setConstantScore

setConstantScore(pConstantScore): NestedPattern

Specifies a constant score value for this therm.

All matching hits for this term will then always return the same fixed value that is later used to calculate the overall document score.

This is useful when using nested queries, which are mainly used for filtering, in order not to distort the score of the document, or to adjust it only in a limited way.

The value must always be a positiv value grater or equal to 0.0. If set to NULL (default) no constant scoring is used.

Parameters

pConstantScore
number

the value used as constant score or NULL for none.

Returns

NestedPattern

setEntityField

setEntityField(pEntityField): NestedPattern

Not supported for nested patterns. This is a special case for index terms that does not accept field names. Calling this function has no effect.

Parameters

pEntityField
string | number | boolean

the name of the entity field.

Returns

NestedPattern

setIndexField

setIndexField(pIndexFieldName): NestedPattern

Not supported for nested patterns. This is a special case for index terms that does not accept field names. Calling this function has no effect.

Parameters

pIndexFieldName
string | number | boolean

the name of the index field.

Returns

NestedPattern

Example

<code>// Construct a nested pattern from with a pattern string.
var nestedPattern = indexsearch.createNestedPattern("\"foo bar\" +name:(bar -ba)");

// Add the nested pattern to the config object.
var patternConfig = indexsearch.createPatternConfig()
.or(indexsearch.createTerm("123"))
.and(nestedPattern); // Add like any other term object.

// Build the final pattern string.
// -&gt; 123 +_query_:"{!edismax}\"foo bar\" +name:(bar -ba)"
var pattern = indexsearch.buildPattern(patternConfig);
</code>