WildcardTerm
Creates a wildcard term of the index search. It allows searches with the wildcards * and ? for a term.
-
*: matches zero or more sequential characters. -
?: matches a single character.
As all term typs this type supports the standard functions for setting the field name (entity and index) and the search weighting (boost). The term provides functions for easily creating expressions for matching prefixes (foo*) and postfixes (*foo). It is possible to use both options to get an expression that represents contains (*foo*). NOTE: This function will always create a prefix term by default e.g. foo*. Additional wildcards can also be defined via the value itself. e.g. T?m for matching Tim and Tom. NOTE: Do not add unescaped quoted values ( phrases ), multiple values/words separated by whitespaces (phrases or groups), or values defining a fuzzy search ( ~ ). This will result in an invalid configuration that can not be searched or returns unexpected results. A postfix (*foo) is only generated if this is permitted by the property indexsearchAllowLeadingWildcards, otherwise the flag is ignored. 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
numberThe boost factor of this term.
getEntityField
getEntityField():
string
Returns
stringThe defined entity field in which to search for the value. null if not set.
getIndexField
getIndexField():
string
Returns
stringThe 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
stringThe value to be searched for as a string.
isApplyLeadingWildcard
isApplyLeadingWildcard():
boolean
Flag for the automatic generation of a postfix term with a leading wildcard. A postfix (*foo) is only generated if this is permitted by the indexsearchAllowLeadingWildcards property. Otherwise, the flag is ignored.
Returns
booleantrue, if a postfix is generated.
isApplyTrailingWildcard
isApplyTrailingWildcard():
boolean
Flag for the automatic generation of a prefix term (foo*) with a trailing wildcard.
Returns
booleantrue, if a postfix is generated.
setApplyLeadingWildcard
setApplyLeadingWildcard(
pApplyLeadingWildcard):WildcardTerm
Sets the flag for the automatic generation of a postfix term with a leading wildcard. A postfix (*foo) is only generated if this is permitted by the indexsearchAllowLeadingWildcards property. Otherwise, the flag is ignored.
Parameters
booleantrue if a prefix term should be generated.
Returns
WildcardTermsetApplyTrailingWildcard
setApplyTrailingWildcard(
pApplyTrailingWildcard):WildcardTerm
Sets the flag for the automatic generation of a prefix (foo*) term with a trailing wildcard.
Parameters
booleantrue if a prefix term should be generated.
Returns
WildcardTermsetBoost
setBoost(
pBoost):WildcardTerm
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
WildcardTermsetEntityField
setEntityField(
pEntityField):WildcardTerm
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
string | number | booleanthe name of the entity field.
Returns
WildcardTermsetIndexField
setIndexField(
pIndexFieldName):WildcardTerm
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
string | number | booleanthe name of the index field.
Returns
WildcardTermsetValue
setValue(
pValue):WildcardTerm
Sets the value to search for. The value can not be null.
Parameters
string | number | booleanThe new value to search for.
Returns
WildcardTermExample
<code>import("system.indexsearch");
// This example is meant to show syntax.
// Constructs a new prefix term 'foo*'
var term = indexsearch.createWildcardTerm("foo")
// Constructs a postfix term '*foo'
term.setApplyLeadingWildcards(true)
.setApplyTrailingWildcards(false);
// creates a 'contains' term '*foo*'
term.setApplyLeadingWildcards(true)
.setApplyTrailingWildcards(true);
// Wenn using the default initial term only leading wildcards need to be applied
// to define a 'contains' expression
term = indexsearch.createWildcardTerm("foo")
.setApplyLeadingWildcards(true);
// specifies a field and a boost for the term.
// 'field_value:*foo*^1.3'
term.setEntityField("entityName.FIELD.value")
.setBoost(1.3);
var patternConf = indexsearch.createPatternConfig().or(term);
</code>