PhraseTerm
A phrase term for the index search. A phrase is a group of words surrounded by double quotes such as "foo bar". It allows the search for consecutive words within an index field, e.g. "start the ADITO Designer". This is especially helpful when searching in fields with long texts. As all term typs this type supports the standard functions for setting the field name (entity and index) and the search weighting (boost). A phrase term allows to perform a proximity search by specifying the maximum allowed distance between the words contained in the phrase. A proximity search looks for terms that are within a specific distance from one another. To perform a proximity search, set the proximity via setProximity(pInt). For example, to search for an "Index" and "ADITO" within 10 words of each other in a document, use indexsearch.createPhraseTerm("Index ADITO").setProximity(10). NOTE: Do not add unescaped quoted values (phrases), this term object automatically adds the quotes. This will result in an invalid configuration that can not be searched or returns unexpected results. This term type does not support wildcards. All wildcards and other syntax characters within the phrase are treated as normal characters. 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.
getProximity
getProximity():
number
Returns the proximity of this phrase term, which is used to perform a proximity search. To reset and deactivate the proximity search for a term, set the proximity to 0. Proximity Search: A proximity search looks for terms that are within a specific distance from one another. For example, to search for a "Index" and "ADITO" within 10 words of each other in a document, set the proximity to 10. This constructs a Lucene / Solr search phrase with the given proximity by adding the tilde character ~ and a numeric value at the end of a search phrase. "Index ADITO"~10 The distance referred to here is the number of term movements needed to match the specified phrase. In the example above, if "Index" and "ADITO" were 10 spaces apart in a field, but "Index" appeared before "ADITO", more than 10 term movements would be required to move the terms together and position "Index" to the right of "ADITO" with a space in between.
Returns
numberthe proximity for the search phrase.
Example
import("system.indexsearch");
var phrase = indexsearch.createPhraseTerm("Index ADITO")
.setProximity(10); // Define the proximity to enable the proximity search.
var patternConf = indexsearch.createPatternConfig().or(phrase);
var pattern = indexsearch.buildPattern(patternConf); // Builds "Index ADITO"~10
getValue
getValue():
string
The searched value represented by this term.
Returns
stringThe content of the phrase without the enclosing ".
setBoost
setBoost(
pBoost):PhraseTerm
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
PhraseTermsetEntityField
setEntityField(
pEntityField):PhraseTerm
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
PhraseTermsetIndexField
setIndexField(
pIndexFieldName):PhraseTerm
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
PhraseTermsetProximity
setProximity(
pFuzzySearchFactor):PhraseTerm
Sets the proximity of this phrase term, which is used to perform a proximity search. To reset and deactivate the proximity search for a term, set the proximity to 0. Proximity Search: A proximity search looks for terms that are within a specific distance from one another. For example, to search for a "Index" and "ADITO" within 10 words of each other in a document, set the proximity to 10. This constructs a Lucene / Solr search phrase with the given proximity by adding the tilde character ~ and a numeric value at the end of a search phrase. "Index ADITO"~10 The distance referred to here is the number of term movements needed to match the specified phrase. In the example above, if "Index" and "ADITO" were 10 spaces apart in a field, but "Index" appeared before "ADITO", more than 10 term movements would be required to move the terms together and position "Index" to the right of "ADITO" with a space in between.
Parameters
numberthe proximity for the search phrase.
Returns
PhraseTermExample
import("system.indexsearch");
var phrase = indexsearch.createPhraseTerm("Index ADITO")
.setProximity(10); // Define the proximity to enable the proximity search.
var patternConf = indexsearch.createPatternConfig().or(phrase);
var pattern = indexsearch.buildPattern(patternConf); // Builds "Index ADITO"~10
setValue
setValue(
pValue):PhraseTerm
Sets the value to search for. The value can not be null.
Parameters
string | number | booleanThe new content of the phrase without the enclosing ".
Returns
PhraseTermExample
<code>import("system.indexsearch");
// creates a new phrase term
// '"foo bar"'
var term = indexsearch.createPhraseTerm("foo bar");
// Sets the proximity an enables the proximity search.
// '"foo bar"~10'
term.setProximity(10);
// specifies a field and a boost for the term.
// 'field_value:"foo bar"~10^1.3'
term.setEntityField("entityName.FIELD.value")
.setBoost(1.3);
var patternConf = indexsearch.createPatternConfig().or(term);
</code>