indexsearch
Modul for the index search of the ADITO system.
Allows to create and search specific patterns for the index.
Methods
buildPattern
buildPattern(
pPatternConfig):string
Translates the given IndexPatternConfiguration into a search pattern for the index search.
Parameters
Returns
stringa string that contains the translated index search pattern.
Throws
May throw an exception.
buildPatternString()
buildPatternString(
pPatternConfig):string
Parameters
Returns
stringDeprecated
Element is marked for removal. wurde durch buildPattern ersetzt.
Throws
May throw an exception.
buildQueryFromSearchCondition()
buildQueryFromSearchCondition(
pFilterJson):string
Parameters
string | number | booleanReturns
stringDeprecated
Element is marked for removal. wurde durch toFilterPattern ersetzt.
Throws
May throw an exception.
convertFilterToPattern
convertFilterToPattern(
pEntityOrIndexGroupName,pFilterJson,pUnknownFilterExtensionPolicy):string
Translates a FilterJson into a search pattern for the index search.
The filter will be converted using the context of the entity defining the index group.
If the filter contains filter extensions they will be processed if the extensions exist in the corresponding index record container of the defining entity. When encountering a filter extension unknown by the record container, the converter handels them according to the specified pUnknownFilterExtensionPolicy flag.
Valid options are
-
indexsearch.FILTER_EXTENSION_SYSTEM_DEFAULT: Using global setting specified in the preferences. Default is FILTER_EXTENSION_FAIL
-
indexsearch.FILTER_EXTENSION_FAIL: If set, an exception is thrown when encountering an extension unknown by the index record container.
-
indexsearch.FILTER_EXTENSION_SKIP: If set, unknown extension are skipped an thus not included in the resulting pattern.
NOTE: This method can not process filter extensions if no entity or index group name is specified. Without a valid name the underlying converter can not determine the required record container needed to process the filter extensions in the given FilterJson.
Parameters
string | number | booleanname of the index group or entity the filter belongs to. If set to null no filter extensions are processed.
string | number | booleana json-string defining the filter.
numberflag that defines how unknown filter extensions are handled during translation. Valid options are indexsearch.FILTER_EXTENSION_SYSTEM_DEFAULT, indexsearch.FILTER_EXTENSION_FAIL and indexsearch.FILTER_EXTENSION_SKIP. For all other values indexsearch.FILTER_EXTENSION_FAIL is used by default.
Returns
stringa pattern for the index search with the same conditions as in the given filter.
Throws
May throw an exception.
Example
// Example filter json
var filter = {
"filter":{
"type":"group",
"operator":"AND",
"childs":[
{
"type":"row",
"name":"FIRSTNAME",
"operator":"STARTSWITH",
"value":"Tim",
"key":"",
"contenttype":"TEXT"
}
]
}
};
// Convert filter into a string.
var filterAsString = JSON.stringify(filter);
// Converting the filter by specifying the entity.
var pattern = indexsearch.convertFilterToPattern("Person_entity", filterAsString);
// Converting the filter by specifying the index group.
var pattern = indexsearch.convertFilterToPattern("Person", filterAsString);
// Result pattern: +lastname_value:Lisa*
createGroupTerm
createGroupTerm():
GroupTerm
Creates an empty group 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 group term allows to group terms to form a sub-query. This is very useful to control the Boolean logic for a query. This term object works similar to the IndexPatternConfiguration allowing to append term objects with different operators.
- Sub-query: Create a simple sup-query by simply adding terms without defining a field name for the group. The following term searches for either "Lisa" or "Sommer" and "MeineFirma" (
( Lisa OR Sommer ) AND meineFirma).
Returns
a new empty group term.
Example
<code> // Assume that the following terms are defined firstname['Lisa'], lastname['Sommer']
// and orgName['meineFirma']
// '( Lisa OR Sommer )'
var group = indexsearch.createGroupTerm().or(firstname).or(lastname);
// '( Lisa OR Sommer ) AND meineFirma'
var patternConf = indexsearch.createPatternConfig().or(group).and(orgName);
</code>
The grouped terms can be specified with field names.
Example
<code> // Assume that the followeing terms are defined fistname['firstname_value:Lisa'],
// lastname['lastname_value:Sommer'] and orgName['name_value:meineFirma']
// '( firstname_value:Lisa OR lastname_value:Sommer )'
var group = indexsearch.createGroupTerm().or(firstname).or(lastname);
// '( firstname_value:Lisa OR lastname_value:Sommer ) AND name_value:meineFirma'
var patternConf = indexsearch.createPatternConfig().or(group).and(orgName);
</code>
- Grouping clauses within a index field: To apply two or more Boolean operators to a single index field in a search, add the Terms (without a field name) for the desired field to a single group and set the field name of the group term to the desired field. For example, the following group searches for a firstname field that matches "L*" but not "Lisa" (
firstname_value:( +L* -Lisa )).
Example
<code> // Assume that the following terms are defined prefixTerm['L*'] and singleName['Lisa']
// '( +L* -Lisa )'
var group = indexsearch.createGroupTerm().plus(prefixTerm).minus(singleName);
// Specify the field for the hole group.
group.setEntityField("Person_entity.FIRSTNAME");
// 'firstname_value:( +L* -Lisa )'
var patternConf = indexsearch.createPatternConfig().or(group);
</code>
This term object provides an isEmpty() method, that will return true if no terms where added. NOTE: Do not add empty group terms to an IndexPatternConfiguration or another group term. This can cause the resulting pattern to fail. Example:
Example
import("system.indexsearch");
var patternConf = indexsearch.createPatternConfig();
var a = indexsearch.createTerm("A");
var b = indexsearch.createTerm("B");
var c = indexsearch.createTerm("C");
var group = indexsearch.createGroupTerm();
// Add terms (a & b) to the group.
// '( A B )'
group.or(a).or(b);
// specifies a field and a boost for the group term.
// 'field_value:( A B )^1.3'
term.setEntityField("entityName.FIELD.value")
.setBoost(1.3);
// Add the group to a pattern configuration.
// '+( A B ) +C'
patternConf.plus(group).plus(c);
// result => +field_value:( A B )^1.3 +C
var pattern = indexsearch.buildPatternString(patternConf);
createIncrementalIndexerRunConfig
createIncrementalIndexerRunConfig():
IncrementalIndexerRunConfig
Creates a configuration object for the incremental indexer.
Returns
RunIncrementalIndexerConfig
createIndexQuery
createIndexQuery():
IndexQuery
Creates a new configuration object to query the index search.
Returns
a new index query configuration.
Throws
AditoIllegalArgumentException
Example
var query = indexsearch.createIndexQuery();
// creates a new configuration query.setPattern("Lisa Sommer") // sets the search pattern. .addEntities(["Person_entity"]) // specifies the searched entity (must contain an indexRecordContainer) .setRows(10) // sets the max number of results being returned by the index .setApplyTrailingWildcards(true);
// appends '*' to all words in the pattern. var res = indexsearch.searchIndex(query);
// executes the search with the given query.
createJoinQuery
createJoinQuery():
JoinQueryBuilder
Creates a special pattern builder that allows to join and filter index documents based on the content of other documents in another index group.
The join pattern requires two fields on which the join is applied. Only documents with matching values in both fields are joined. from describes the index group which will be joined. The specified field is used as key for the join. to describes the field of the searched index group, which is used to find matching documents of the joined index group. The pattern is only applied on the joined index group and does the actual filtering.
IMPORTANT: The fields used for the join must share compatible index field types. Such as STRING -> STRING, TEXT ->TEXT, TEXT_PLAIN -> TEXT, BOOLEAN -> BOOLEAN.
Most text-based types can be used together, but unexpected results may occur depending on the content, e.g. if only one of the fields contains stop words. The safest way is to always use only two fields of the same type.
Returns
Example
// In this example a index query is created that retrieves
// all organisations for which a open offer exists in the index.
// 1. Create a query object for the actual search.
var indexQuery = indexsearch.createIndexQuery()
.setIndexGroups(["Organisation"]); // set the required index group.
// 2. Create a join query builder that joins organisation with the offer group.
// - In order to work the appropriate 'from' and 'to' fields must be specified.
// 2a. Creates the join query using the respective index groups and fields.
// - The first parameter for 'from' and 'to' is the identifier of the index group
// - The second parameter is index field of the group used for joining.
// -- For the field system field of the index, e.g. 'indexsearch.FIELD_ID' can be used.
// Otherwise the plain name of field 'organisation_contact_id' can be used or with the respective suffixes
// '_value' and '_displayvalue' to distinguish between teh to field variants if needed. (default is '_value')
var joinQ = indexsearch.createJoinQuery()
.setFrom("Offer", "organisation_contact_id") // the field in the target group on which to join.
.setTo("Organisation", indexsearch.FIELD_ID) // the field that is used to join.
.setPattern("statuscode:OPEN"); // the pattern that is applied to filter on the target group
// 2b. Creates the same join query using the entity and the respective entity fields or index system fields.
// - The first parameter is the name of the entity that defines the indexgroup.
// - For the 'setFromEntity' and 'setToEntity' functions, the second parameter is the name of the entity field
// whose corresponding index field is used.
// - For the 'setFromEntityWithIndexField' and 'setToEntityWithIndexField', the second parameter is the name of the index field.
This allows to specify a system field, e.g. 'indexsearch.FIELD_ID', in combination with the entity.
var joinQEntity = indexsearch.createJoinQuery()
.setFromEntity("Offer_entity", "OrganisationContactId.value") // the field in the target group on which to join.
.setToEntityWithIndexField("Organisation_entity", indexsearch.FIELD_ID) // the field that is used to join.
.setPattern("statuscode:OPEN"); // the pattern that is applied to filter on the target group
// 3. Add the final join query as a filter pattern for the actual search.
indexQuery.addFilter(indexsearch.buildPattern(joinQ));
indexserach.searchIndex(indexQuery);
createLocalParamsPattern
createLocalParamsPattern():
LocalParamsPatternBuilder
Creates a pattern builder that allows to create index patterns that use the local parameter syntax of Solr.
Example for the local parameter syntax: {!lucene q.op=AND df=text}foo bar
The builder provides functions to specify the query parser, set the required parameters and the pattern that will be used. Via the special setter setRawIndexFieldParam it is possible to reference the native index field of the solr index used by the specified index field.
Returns
Example
// The example constructs a pattern that uses local params.
// The resulting pattern will use the lucene query parser of the index to search in a specific index field.
// Note: The pattern must be converted into a nested Query in order to use it as the actual pattern and not as filter.
// The pattern will search all organisations that start with 'A' and also contain 'GmbH' in their name.
// -> {!lucene q.op=AND df=name_value_idx_sto_textnostopwords}A* GmbH
// Create the local parameter pattern builder
var localParamsBuilder = indexsearch.createLocalParamsPattern()
.setType("lucene") // Specify the requested query parser.
.setParam("q.op", indexsearch.OPERATOR_AND) // Set the parameter for the default operator.
.setRawIndexFieldParam("df", "Organisation", "name_value") // Specify an index field for a parameter.
.setPattern("A* GmbH"); // Set the pattern used by the specified parser.
// Construct the embedded pattern used for the search
// -> +_query_:"{!lucene q.op=AND df=name_value_idx_sto_textnostopwords}A* GmbH"
var pattern = indexsearch.buildPattern(
indexsearch.createPatternConfig()
.plus(localParamsBuilder.asNestedPattern()));
// Create an index query for the pattern limited to search only for organisations.
var indexQuery = indexsearch.createIndexQuery()
.setPattern(pattern)
.setIndexGroups(["Organisation"]);
indexserach.searchIndex(indexQuery);
createNestedPattern
createNestedPattern(
pPattern):NestedPattern
Creates an 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_.
Parameters
string | number | booleanthe index pattern that will be executed as nested pattern.
Returns
Example
// 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);
createPatternConfig
createPatternConfig():
IndexPatternConfig
Creates a new configuration object for defining a pattern for the index search. A search pattern can be created with the configuration object without knowing the specific syntax required for the pattern. The individual search terms are defined in the form of term objects, which are then added to the pattern configuration. The configuration is similar to a builder pattern and offers functions to add terms with different operators. The order in which the terms are added indicates the order in the final pattern. NOTE: The order of the terms cannot be changed after they have been added. After configuration the pattern can build by calling the function indexsearch.buildPattern(pPatternConfig) All terms can be created using the corresponding indexsearch.createXXXTerm() functions. Apart from the specific methods of the individual term types, each type supports the standard functions for setting the field name (entity and index) and the search weighting (boost). Available Terms:
-
Simple index term (createTerm): Creates a simple term object for a single value. e.g.
Lisaorfirstname_value:Lisa -
Wildcard term (createWildcardTerm): Creates a wildcard term for searching prefixes (
foo*), postfixes (*foo) and word parts (*foo*). -
Phrase term (createPhraseTerm): Creates a phrase that contains a text or sentence in quotation marks. e.g.
"Lisa Sommer". -
Range term (createRangeTerm): Creates a term to find matches within a range of numbers, characters, or words (alphabetically). e.g.
[1 TO 2],[f TO *]or[search TO searching] -
Group term (createGroupTerm): Creates a term that represents a group of terms that belong together. e.g.
( +Lisa +Sommer ) OR l.sommer@domain.localThis object is empty after creation()and allows to add terms similar to the pattern configuration. By using a group, it is possible to search for a number of terms in a single index field without specifying each field for each term. e.glastname_value:( Sommer Admin Leicht )
Returns
a new pattern configuration object for the index search.
Example
import("system.indexsearch");
// firstname_value:Lisa
var term = indexsearch.createTerm("Lisa")
.setEntityField("Person_entity.FIRSTNAME");
// lastname_value:S*^1.4
var wildcard = indexsearch.createWildcardTerm("S")
.setIndexField("lastname_value")
.setBoost(1.4);
// "foo bar"~2
var phrase = indexsearch.createPhraseTerm("foo bar")
.setProximity(2);
// indexzip_value:[84000 TO 85000]
var range = indexsearch.createRangeTerm("84000", "86000")
.setEntityField("Person_entity.IndexZIP");
// ( +firstname_value:Lisa +lastname_value:S*^1.4 )
var name_group = indexsearch.createGroupTerm()
.plus(term)
.plus(wildcard);
//create the final pattern configuration.
//( +firstname_value:Lisa +lastname_value:S*^1.4 ) -"foo bar"~2 +indexzip_value:[84000 TO 85000]
var patternConf = indexsearch.createPatternConfig()
.or(name_group)
.minus(phrase)
.plus(range);
// build the pattern and returns the result as a string.
var pattern = indexsearch.buildPattern(patternConf);
createPhraseTerm
createPhraseTerm(
pPhrase):PhraseTerm
Creates 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.
Parameters
string | number | booleanThe initial value represented by this term.
Returns
a new phrase term containing the given set of words (or sentence), e.g. "this is a phrase".
Example
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);
createRangeTerm
createRangeTerm(
pStart,pEnd):RangeTerm
Creates 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.
Parameters
string | number | booleanThe initial start (upper limit) of the range term, null for no upper limit.
string | number | booleanThe initial end (lower limit) of the range term, null for no lower limit.
Returns
a new range term with the specified start and end. The borders are included by default.
Example
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);
createSpatialSearchExtension
createSpatialSearchExtension():
SpatialSearchExtension
Creates a new configuration object for a spatial search using the index. The configuration object serves as an extension for an existing IndexQuery and offers the possibility to filter and score results according to distance. The search is always based on the specified center point (required) and the distance in km (default 25). The default method is SPATIAL_METHOD_RADIUS Unless otherwise defined, the search is carried out on the #LOCATION ('location') system field of the index.
Returns
a new spatial search configuration object for the index search.
Example
var spatialExt = indexsearch.createSpatialSearchExtension() .setMethod(indexsearch.SPATIAL_METHOD_RADIUS) // setting the search method (default: radius) .setCenterPoint(50.0, 50.0) // setting the center point (required!) .setDistance(10.0) // setting a new distance in km (default: 25) .setFilterResults(true) // enable / disable filtering of results outside the given distance (default: true) .setBoostNearestResults(false);
// enable / disable scoring of results by distance (default: true) var query = indexsearch.createIndexQuery().addExtension(spatialExt);
// adding the extension to an index query indexsearch.searchIndex(query);
createTerm
createTerm(
pTermValue):IndexTerm
Creates a default term for the index search representing a single search condition. e.g. "firstname_value:lisa~^1.2" As all term typs this type supports the standard functions for setting the field name (entity and index) and the search weighting (boost). The value can not be null. Fuzzy search: This term type provides the option to perform a fuzzy search (~) by setting a factor using term.setFuzzySearchFactor(pInt). Fuzzy searches discover terms that are similar to a specified term without necessarily being an exact match. The comparison is carried out at the character level and searches for values ??that match to the expression with the specified maximum of different characters. Differences in length count as change. The expression will always match exact matches. The maximum supported amount of differences is 2. Examples: The expression roam~ ( max 2 differences ) will match terms like roams, foam and foams. The expression roam~1 will match terms like roams and foam - but not foams since it has an edit distance of "2". 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. It will always break the fuzzy search which is only supported by simple terms without wildcards. The term object must be added to an IndexPatternConfig or a group term in order to create an index search pattern.
Parameters
string | number | booleanThe initial value represented by this term.
Returns
A new term with the given initial value.
Example
import("system.indexsearch");
// This example is meant to show syntax.
// Constructs the term 'field_value:foo^1.3'
var term = indexsearch.createTerm("foo")
.setEntityField("entityName.FIELD.value")
.setBoost(1.3);
// Constructs a fuzzy search term 'bar~' using max differences of 2.
term = indexsearch.createTerm("bar")
.setFuzzySearchFactor(0);
// Constructs a fuzzy search term 'foo:bar~1'
// matching the value 'bar' with 1 difference in the field 'foo'.
term.setIndexField("foo").setFuzzySearchFactor(1);
var patternConf = indexsearch.createPatternConfig().or(term);
createWildcardTerm
createWildcardTerm(
pTermValue):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.
Parameters
string | number | booleanThe initial value represented by this term.
Returns
a new wildcard term matching the given value as a prefix e.g. foo*.
Example
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);
escapeString
escapeString(
pS):string
Escapes all syntax characters of the index search in the passed string. Syntax Characters: + - & | ! ( ) { } [ ] ^ " ~ * ? : / If the indexsearch is deactivated the original pattern is returned. Example: "+foo & bar! foo-bar" -> "\+foo \& bar\! foo\-bar"
Parameters
string | number | booleanThe string from which the syntax characters are to be escaped.
Returns
stringThe new string with escaped syntax characters.
escapeStringExcludeSigns
escapeStringExcludeSigns(
pS,pExcludedSigns):string
Escapes all index search syntax characters in the passed string, except for the specified excluded characters. Syntax Characters: + - & | ! ( ) { } [ ] ^ " ~ * ? : / If the indexsearch is deactivated the original pattern is returned. Example: indexsearch.escapeStringExcludeSigns("f?o - *bar!", "*?") returns "f?o \- *bar\!".
Parameters
string | number | booleanThe string from which the syntax characters are to be escaped.
string | number | booleanA String containing the syntax characters which are not escaped. E.g.: "*?".
Returns
stringThe new string with escaped syntax characters.
lookupIndexField
lookupIndexField(
pEntityName,pEntityField):string
Returns the name of the defined index field for the given entity field. For Example indexsearch.lookupIndexField("Person_entity", "LASTNAME") will return "lastname_value". NOTE: This function will always return null if the index search is disabled or when using a legacy index ('isUseLegacyConfiguration').
Parameters
string | number | booleanThe entity in which the field is defined.
string | number | booleanThe name of the entity field including .value and .displayValue. The plain field name ist handled as if .value was specified.
Returns
stringThe name of the corresponding index field for the given entity field.
Throws
May throw an exception.
runIncrementalIndexer
runIncrementalIndexer(
pConfig):void
Runs the incremental indexer for the specified group and uids. Optionally, indexing can be carried out immediately, without delay. If the indexserach is deactivated nothing will happen.
Parameters
Returns
voidThrows
May throw an exception.
Example
// Add the indexing task to a queue.
// This will group similar tasks and maximize efficiency.
const config = indexsearch.createIncrementalIndexerRunConfig()
.group("Employee")
.addUid("a6d56c55-b06c-44f5-9095-02d46c3504db")
.addUids(["3b2e77bf-116c-45fb-9ca7-e060f4157afc", "0693d17d-acb3-4757-b818-4bf87263a1a8"]);
indexsearch.runIncrementalIndexer(config);
</code>
<code>
// Run the incremental indexer without delay.
const config = indexsearch.createIncrementalIndexerRunConfig()
.group("Employee")
.addUid("a6d56c55-b06c-44f5-9095-02d46c3504db")
.addUids(["3b2e77bf-116c-45fb-9ca7-e060f4157afc", "0693d17d-acb3-4757-b818-4bf87263a1a8"])
.runImmediately();
indexsearch.runIncrementalIndexer(config);
Throws
AditoIllegalStateException
runIndexer
runIndexer(
pGroups):void
Starts indexing for the index search. If the indexserach is deactivated nothing will happen.
Parameters
string[]The names of the index groups to be synchronized; 'null' to synchronize all groups.
Returns
voidThrows
May throw an exception.
Example
indexsearch.runIndexer(null);
//all groups indexsearch.runIndexer(["PERS", "ORG"]);
// PERS and ORG indexsearch.runIndexer(["PERS", "ORG", "POST", "OFFER", "SALESORDER"]);
//PERS, ORG, POST, OFFER, SALESORDER
search
search(
pPattern,pCalculateGroupInfo,pGroups,pResultCount?,pResultGroupCount?,pDisablePatternExtension?):Map<any,any>
Searches in the index to find a pattern.
Parameters
string | number | booleanThe search pattern.
boolean'true', calculates group information.
string[]The groups / types to be searched.
numberMaximum number of hits (0 for all).
numberMaximum number of groups (0 for all). The groups are the names of the index searches that have been defined in the alias editor.
booleanDisables the indexsearch_patternextension process for this index search.
Returns
Map<any, any>The result of the index search as a map.
Throws
May throw an exception.
Example
var hit = indexsearch.search( "(" + searchstring + ")" , false, ["CAMPAIGNPARTICIPANTSTEP"], 100, 3, true);
var result = hit["HITS"];
var actual = hit["TOTALHITS"];
question.showMessage("Hits: " + result + " Total hits: " + actual);
searchIndex
searchIndex(
pIndexQuery):Map<any,any>
Performs an index search with the given index query.
Example search with result.
Parameters
Returns
Map<any, any>the result of the index search.
Throws
May throw an exception.
Example
var indexQuery = indexsearch.createQuery() // Creates a new query object for the index .setPattern("My Company") // sets the requested pattern .setSearchFields(["Person_entity.NAME", "Organisation_entity.NAME"]);
// Specifies the fields to be searched when no explicit feldname is defined in the pattern. .setEntities(["Person_entity", "Organisation_entity]) // Sets the entities whose index groups are to be searched. .setTagResultEnabled(true) // Activates the result object for the overall global search tags of the result. .setTagLimit(5) // Limits maximum amount of returned tags to 5. .setDefaultOperator(indexserach.OPERATOR_AND) // Sets the default operator of the patten -> 'My AND Company" .setRows(5);
// Sets the maximum amount of returned hits. var searchResult = indexsearch.searchIndex(indexQuery);
// Example result as JSON // { // "HITS":[ // { // "id":"Organisation-123", // "_local_id_":"123", // "_title_":"My Company", // "_description_":"A company..." // "_index_group_":"Organisation" // "_tags_":["#A", "#B"] // }, // { // "id":"Person-987", // "_local_id_":"987", // "_title_":"My Company", // "_description_":"A company..." // "_index_group_":"Person" // "_tags_":["#A"] // }, // // ], // "GROUPS":[ // { // "GROUPNAME":"Organisation", // "GROUPHITS":"1" // }, // { // "GROUPNAME":"Person", // "GROUPHITS":"1" // } // // ], // "TOTALGROUPS":2, // "SUBGROUPS":null, // "TOTALHITS":2, // "TAGS":[ // { // "TAGNAME":"#A", // "TAGHITS":"2" // }, // { // "TAGNAME":"#B", // "TAGHITS":"1" // } // ] // }
toFilterPattern
toFilterPattern(
pFilterJson):string
Translates a FilterJson into a search pattern for the index search.
NOTE: This method can not process filter extensions. Without specifying an entity or index group the underlying converter can not determine the required record container, needed to process the filter extensions in the given FilterJson.
The converter uses the global default action (indexsearch.FILTER_EXTENSION_SYSTEM_DEFAULT) defined in the preferences when encountering any filter extensions during translation. (Default is FAIL).
If a different policy for unknown filter extensions is required use indexsearch.convertFilterToPattern(null, pFilterJson, pUnknownFilterExtensionPolicy) instead.
If any of the contained filter extensions needs to be included in the filter use indexsearch.convertFilterToGroupPattern(pEntityOrIndexGroupName, pFilterJson, pUnknownFilterExtensionPolicy) and specify the name of the required entity or index group.
Parameters
string | number | booleana json-string defining the filter.
Returns
stringa pattern for the index search with the same conditions as in the given filter.
Throws
May throw an exception.
Properties
ALL
stringSearch with all available locales.
FIELD_DESCRIPTION
stringResult of the index search: Description of the hit (for hits)
FIELD_ID
stringResult of the index search: Hit ID (for hits)
FIELD_SUBTYPE
stringResult of the index search: Hit subtype (for hits)
FIELD_TAGS
stringResult of the index search: Hit global search tags (for hits)
FIELD_TITLE
stringResult of the index search: Hit title (for hits)
FIELD_TYPE
stringResult of the index search: Hit type (for hits)
FILTER_EXTENSION_FAIL
numberPolicy that is used when translating a JSON filter into an index pattern if the filter contains unknown filter extensions.
Indicates that an exception will be thrown when the filter is compiled if the filer contains an unknown filter extension.
FILTER_EXTENSION_SKIP
numberPolicy that is used when translating a JSON filter into an index pattern if the filter contains unknown filter extensions.
Specifies that all unknown filter extensions are skipped when the filter is translated. They are not included in the pattern after translation
FILTER_EXTENSION_SYSTEM_DEFAULT
numberPolicy that is used when translating a JSON filter into an index pattern if the filter contains unknown filter extensions.
Indicates that the global policy of the system is used when translating the filter. The default for the global policy is FAIL if this was not explicitly set in the preferences.
GROUPHITS
stringResult of the index search: Number of hits in the group (for groups)
GROUPNAME
stringResult of the index search: Group name (for groups)
GROUPS
stringResult of the index search: Groups found (array)
HITS
stringResult of the index search: Hits found (array)
NO_SUB_GROUP
stringVirtual name of the subgroup for filtering documents in an index group without a subgroup.
Example
// returns all documents of the index group 'Organisation' that do not belong to a subgroup. indexQuery.setSubGroupsByIndexGroup("Organisation", indexsearch.NO_SUB_GROUP);
OPERATOR_AND
stringOperator AND to concatenate the keywords
OPERATOR_OR
stringOperator OR to concatenate the keywords
SPATIAL_METHOD_BOX
stringThe box method is very similar to the radius except it uses the bounding box of the calculated circle. It takes the same parameters as radius. The rectangular shape is faster to compute and so it can be used sometimes as an alternative to the radius method when it’s acceptable to return points outside of the radius.
Example
indexsearch.createSpatialSearchExtension().setMethod(indexsearch.SPATIAL_METHOD_BOX);
SPATIAL_METHOD_RADIUS
stringThe radius method allows you to retrieve results based on the geospatial distance from a given point. Another way of looking at it is that it creates a circular shape filter. This option is the default setting.
Example
indexsearch.createSpatialSearchExtension().setMethod(indexsearch.SPATIAL_METHOD_RADIUS);
SPECIFIC
stringSearch only with the specified locale.
SUBGROUPS
stringResult of the index search: Subgroups found (map).
The name of the index group is key for the corresponding subgroups (array). If an index group does not have any subgroups the entry in the map is NULL.
Example
var subgroups = indexRes[indexsearch.SUBGROUPS];
persSubgroups = subgroups["Person"];
// alle subgroups (array or NULL) for index group 'Person' if(persSubgroups) { var i;
for(i = 0;
i <
persSubgroups.length, i++) { var subgroup = persSubgroup[i][indexsearch.GROUPNAME];
// Subgroup name var count = persSubgroup[i][indexsearch.GROUPCOUNT];
// SubGroup count logging.log("person subgroup:" + subgroup + ":" + count);
} }
TAGHITS
stringResult of the index search: Number of hits for a global search tag (for tags)
TAGNAME
stringResult of the index search: The actual global search tag (#) (for tags)
TAGS
stringResult of the index search: Global search tags (#) found (array)
TOTALGROUPS
stringResult of the index search: Total number of groups
TOTALHITS
stringResult of the index search: Total number of hits
WILDCARD_MULTIPLE_CHARS
stringWildcard * to match multiple characters.
WILDCARD_SINGLE_CHAR
stringWildcard ? to match a single character.
WITH_FALLBACK
stringSearch with the specified locale but also use the fallback locale.