RangeTerm
A range term for the index search. As all term typs this type supports the standard functions for setting the field name (entity and index) and the search weighting (boost). A range term defines a search for a range of values for a field (a range with an upper limit and a lower limit). The query matches documents whose values fall within the range. Range queries can include or exclude the upper and lower limits. Sorting is lexicographically, except for numeric fields. The following range term corresponds, for example, to all documents whose zip code field (zip) has a value between 84000 and 85000 inclusive. indexsearch.createRangeTerm(84000, 85000).setEntityField("entity.ZIP") ( translates to zip_value:[84000 TO 85000] ) A range term allows to:
-
Specify the start (upper limit) of the range via
setRangeStart(pInt). An unlimited 'upper limit' can be defined by setting the start tonull, e.g.indexsearch.createRangeTerm(null, "foo")translates to[* TO foo]. This will match all terms lexicographically before 'foo', including 'foo'. -
Specify the end (lower limit) of the range via
setRangeEnd(pInt). An unlimited 'lower limit' can be defined by setting the end tonull, e.g.indexsearch.createRangeTerm("foo", null)translates to[foo TO *]. This will match all terms lexicographically after 'foo', including 'foo'. -
Exclude or include the start (upper limit) from the search. This can be specified using the
setIncludeStart(pBoolean)function of the range term. Usetrueto include the border andfalseto exclude it. The borders (start and end) are included by default. -
Exclude or include the end (lower limit) from the search. This can be specified using the
setIncludeEnd(pBoolean)function of the range term. Usetrueto include the border andfalseto exclude it. The borders (start and end) are included by default.
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. 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.
getRangeEnd
getRangeEnd():
string
Returns the end (lower limit) of the range term. null is returned if no end (lower limit) was defined.
Returns
stringThe end (lower limit) of the range term.
getRangeStart
getRangeStart():
string
Returns the start (upper limit) of the range term. null is returned if no start (upper limit) was defined.
Returns
stringThe start (upper limit) of the range term.
isIncludeEnd
isIncludeEnd():
boolean
Returns if the end (lower limit) should be excluded or included from the search. The borders (start and end) are included by default.
Returns
booleantrue if the end (lower limit) should be included.
isIncludeStart
isIncludeStart():
boolean
Returns if the start (upper limit) should be excluded or included from the search. The borders (start and end) are included by default.
Returns
booleantrue if the start (upper limit) should be included.
setBoost
setBoost(
pBoost):RangeTerm
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
RangeTermsetEntityField
setEntityField(
pEntityField):RangeTerm
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
RangeTermsetIncludeEnd
setIncludeEnd(
pIncludeEnd):RangeTerm
Specifies if the end (lower limit) should be excluded or included from the search. Use true to include the border and false to exclude it. The borders (start and end) are included by default.
Parameters
booleantrue if the end (lower limit) should be included.
Returns
RangeTermsetIncludeStart
setIncludeStart(
pIncludeStart):RangeTerm
Specifies if the start (upper limit) should be excluded or included from the search. Use true to include the border and false to exclude it. The borders (start and end) are included by default.
Parameters
booleantrue if the start (upper limit) should be included.
Returns
RangeTermsetIndexField
setIndexField(
pIndexFieldName):RangeTerm
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
RangeTermsetRangeEnd
setRangeEnd(
pEnd):RangeTerm
Specifies the end (lower limit) of the range term. An unlimited 'lower limit' can be defined by setting the end to null, e.g. indexsearch.createRangeTerm("foo", null) translates to [foo TO *]. This will match all terms lexicographically after 'foo', including 'foo'.
Parameters
string | number | booleanThe end (lower limit) of the range term.
Returns
RangeTermsetRangeStart
setRangeStart(
pStart):RangeTerm
Specifies the start (upper limit) of the range term. An unlimited 'upper limit' can be defined by setting the start to null, e.g. indexsearch.createRangeTerm(null, "foo") translates to [* TO foo]. This will match all terms lexicographically before 'foo', including 'foo'.
Parameters
string | number | booleanThe start (upper limit) of the range term
Returns
RangeTermExample
<code>import("system.indexsearch");
// creates a new range term
// '[84000 TO 85000]'
var term = indexsearch.createRangeTerm("84000", "85000");
// Excludes both borders form the search
// '{84000 TO 85000}'
term.setIncludeStart(false)
.setIncludeEnd(false);
// Creates a range term with an open "upper limit".
// '[* TO foo]'
term = indexsearch.createRangeTerm(null, foo);
// Defines an open 'lower limit'.
// '[* TO *]' -> works like a search all query '*:*'
term.setRangeEnd(null);
// specifies a field and a boost for the term.
// 'field_value:[* TO *]^1.3'
term.setEntityField("entityName.FIELD.value")
.setBoost(1.3);
var patternConf = indexsearch.createPatternConfig().or(term);
</code>