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
numberThe 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
numberthe 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
stringalways 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
stringalways 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
numberthe boost factor of this term.
Returns
NestedPatternsetConstantScore
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
numberthe value used as constant score or NULL for none.
Returns
NestedPatternsetEntityField
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
string | number | booleanthe name of the entity field.
Returns
NestedPatternsetIndexField
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
string | number | booleanthe name of the index field.
Returns
NestedPatternExample
<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.
// -> 123 +_query_:"{!edismax}\"foo bar\" +name:(bar -ba)"
var pattern = indexsearch.buildPattern(patternConfig);
</code>