IndexQuery
Configuration object for defining a search request for the index search. Query configuration is used to search the index and allows to configure general search settings. To perform the search use indexsearch.searchIndex(pIndexQuery). Common settings:
-
setPattern: Specifies the main pattern for the search. If not set, the query's main pattern is treated as a "search all" pattern (
*:*). -
addFilter: Adds an additional filter pattern for the search. A filter pattern is executed on the result set of the main pattern or the result set of a previous filter. It is used to filter the returned results by the given condition. NOTE: The filter must be a pattern for the index search!
-
setStart: A parameter for paging. It defines the start row from which the result is returned. The default is 0, defining for the beginning of the hole result.
-
setRows: This parameter specifies the number of rows (documents) returned from the result, starting from the specified start index.
-
setEntities invalid input: '&' setIndexGroups: Both methods specify the index groups for the search.
setEntitiesallows to specify the index groups over the defining entity. The actual names of the groups a looked up during translation.setIndexGroupsallows to specify the searched groups directly without lookup. The search is limited to the index groups defined in the index query. If no index groups are specified, all groups are searched. -
setDisablePatternExtension: Specifies if the patternExtensions of the searched index groups should be added to this request.
-
setDefaultOperator: Specified the default operator used for the main pattern. Possible values are
OR(indexsearch.OPERATOR_OR) andAND(indexsearch.OPERATOR_AND). The default isOR. NOTE: This only effects the main pattern. filter patterns always useORas the default operator. The patterns generated with an IndexPatternConfiguration work best with the default operatorOR
Example code:
Methods
addBoostPattern
addBoostPattern(
pBoostPattern):IndexQuery
Adds a boost pattern through which the weighting of the results for ranking can be influenced. NOTE: The boost pattern must be a pattern for the index search!
Parameters
string | number | booleanthe boost pattern
Returns
IndexQueryIndexQuery
addEntities
addEntities(
pEntities):IndexQuery
Adds index groups to the search by their defining entity. Entities previously defined are not deleted. The actual index groups are looked up for each defined entity during the searchIndex call. The entity must contain an active IndexRecordContainer. Search will fail if an index group cannot be found for any of the specified entities. The search is limited to the index groups defined in the index query. If no index groups are specified, all groups are searched.
Parameters
string[]The names of the entities containing the actual index groups.
Returns
IndexQueryIndexQuery
addExcludedTags
addExcludedTags(
pIncludedTags):IndexQuery
Adds global tags which must not be contained in the elements of the result (hits).
Excluded tags always use the AND operator for filtering.
Parameters
string[]Returns
IndexQueryindexQuery
addExtension
addExtension(
pQueryExtension):IndexQuery
Adds the extension to the IndexQuery. The exact way the IndexQuery is extended depends on the extension type.
Parameters
IIndexQueryExtensionthe extension
Returns
IndexQueryindexQuery
addFilter
addFilter(
pFilter):IndexQuery
Adds an additional filter pattern to the search. A filter pattern is executed on the result set of the main pattern or the result set of a previous filter. It is used to filter the returned results by the given condition. NOTE: The filter must be a pattern for the index search!
Parameters
string | number | booleanthe Filter
Returns
IndexQueryIndexQuery
addIncludedTags
addIncludedTags(
pIncludedTags):IndexQuery
Adds global tags which must be contained in the elements of the result (hits).
How the tags are filtered depends on the selected operator. Default is AND.
Parameters
string[]Returns
IndexQueryindexQuery
addIndexGroups
addIndexGroups(
pGroups):IndexQuery
Adds index groups to the search by name. Groups previously defined are not deleted. The search is limited to the index groups defined in the index query. If no index groups are specified, all groups are searched.
Parameters
string[]The names of the index groups.
Returns
IndexQueryIndexQuery
addResultFields
addResultFields(
pResultFields):IndexQuery
Adds and defines the index fields contained in the result documents based on the specified entity fields. Entity fields previously defined are not overwritten. The result fields parameter limits the information included in an index search result to a specified list of fields. The names of the entity fields 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 fields are looked up when calling searchIndex. The search fails if an index field cannot be determined for an entity field. To use an index field as a result field, the stored property in the corresponding IndexRecordField must be set to true. If no result fields are specified, all possible fields are returned.
Parameters
string[]The names of the entity fields.
Returns
IndexQueryIndexQuery
addResultIndexFields
addResultIndexFields(
pResultFields):IndexQuery
Adds and defines the index fields contained in the result documents. Index fields previously defined are not overwritten. The result fields parameter limits the information included in an index search result to a specified list of fields. To use an index field as a result field, the stored property in the corresponding IndexRecordField must be set to true. If no result fields are specified, all possible fields are returned.
Parameters
string[]The index fields contained in the result documents.
Returns
IndexQueryIndexQuery
addSearchFields
addSearchFields(
pFields):IndexQuery
Adds and defines entity fields whose corresponding index field is to be searched. Entity fields previously defined are not overwritten. The names of the entity fields 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 fields are looked up when calling searchIndex. The search fails if an index field cannot be determined for an entity field. To use an index field as a search field, the indexed property in the corresponding IndexRecordField must be set to true. If no search fields are specified, all fields are searched.
Parameters
string[]the names of the entity fields to be searched.
Returns
IndexQueryIndexQuery
addSearchIndexFields
addSearchIndexFields(
pFields):IndexQuery
Adds and defines index fields to be searched. Index fields previously defined are not overwritten. To use an index field as a search field, the indexed property in the corresponding IndexRecordField must be set to true. If no search fields are specified, all fields are searched.
Parameters
string[]the names of the index fields to be searched.
Returns
IndexQueryIndexQuery
addSubGroupsByEntity
addSubGroupsByEntity(
pEntity,pSubGroups):IndexQuery
Adds the subgroups of the given entity's index group to the search. The search for the given entity's index group is limited to the subgroups defined in the index query. If the entity's index group of the specified subgroups is excluded from search, all defined subgroups of that index group are ignored.
Parameters
string | number | booleanThe names of the entity.
string[]The subgroups used to filter results for the given entity's index group.
Returns
IndexQueryIndexQuery
addSubGroupsByIndexGroup
addSubGroupsByIndexGroup(
pIndexGroup,pSubGroups):IndexQuery
Adds the subgroups of the given index group to the search. The search for the given index group is limited to the subgroups defined in the index query. If the index group of the specified subgroups is excluded from search, all defined subgroups of that index group are ignored.
Parameters
string | number | booleanThe names of the index group.
string[]The subgroups used to filter results for the given index group.
Returns
IndexQueryIndexQuery
getAutomaticEscapeExcludedSigns
getAutomaticEscapeExcludedSigns():
string
Returns the syntax characters as a string that are excluded by the auto escape feature. If not set, null is returned and all syntax characters are escaped. Syntax Characters: + - invalid input: '&' | ! ( ) { } [ ] ^ " ~ * ? : / Example which uses the auto escape feature and preserves the wildcards defined in the pattern.
Returns
stringthe specified excluded syntax characters as a string, or null.
Example
import("system.indexsearch");
var indexQuery = indexsearch.createIndexQuery();
// This example defines a pattern containing some invalid syntax characters.
// Auto escaping is enabled in order to escape the invalid characters before search.
// The wildcards in the pattern should be preserved so they are excluded from the auto escape.
indexQuery.setPattern("f?o - *bar!") // Defines the invalid pattern.
.setAutomaticEscape(true) // Enables auto escaping.
.setAutomaticEscapeExcludedSigns("*?"); // Excludes the wildcard characters.
// This results in the pattern 'f?o \- *bar\!'
var res = indexsearch.searchIndex(indexQuery)
getBoostPatterns
getBoostPatterns():
string[]
Returns all boost patterns that are used to rank the results of the main pattern. An empty array is returned if no boost pattern was specified.
Returns
string[]The defined filter patterns for the search.
getDefaultOperator
getDefaultOperator():
string
The defined default operator used for the main pattern. Possible values are OR (indexsearch.OPERATOR_OR) and AND (indexsearch.OPERATOR_AND). If not set, null is returned and the implicit default operator OR is used.
Returns
stringthe specified default operator or null if not set.
getEntities
getEntities():
string[]
Returns a list of the specified entities that define the index groups to be searched. If no entities are specified an empty array is returned.
Returns
string[]The names of the entities that define the index groups to be searched.
getExcludedTags
getExcludedTags():
string[]
Returns an array of all global tags which must not be contained in the elements of the result (hits).
Excluded tags always use the AND operator for filtering.
Returns
string[]an array of all tags that are excluded from the search.
getExtensions
getExtensions():
IIndexQueryExtension[]
Returns all current extensions which have been added to this IndexQuery.
Returns
IIndexQueryExtension[]the current extensions of this IndexQuery.
getFilters
getFilters():
string[]
Returns all filter patterns that are used to filter the result of the main pattern. An empty array is returned if no filter was specified.
Returns
string[]The defined filter patterns for the search.
getIncludedTags
getIncludedTags():
string[]
Returns an array of all global tags which must be contained in the elements of the result (hits).
How the tags are filtered depends on the selected operator. Default is AND.
Returns
string[]an array of all tags that are included in the search.
getIncludedTagsOperator
getIncludedTagsOperator():
string
Returns the operator used for filtering the global tags included in the search. Default is AND.
NOTE: This method always returns NULL if the operator is not explicitly set. Internally, the default is still used in this case.
Returns
stringthe current explicitly defined operator for included global tags, NULL otherwise.
getIndexGroups
getIndexGroups():
string[]
Returns a list of the specified index groups to be searched. If no groups are specified an empty array is returned. NOTE: The list does not contain the groups that were specified via the corresponding entities.
Returns
string[]The identifiers of the index groups to be searched.
getLocale
getLocale():
string
Flag that specifies the locale that is to be used for search queries.
Returns
stringthe locale or null
Throws
AditoIllegalArgumentException
getPattern
getPattern():
string
Returns
stringThe main pattern for the search. null if none was specified.
getResultFields
getResultFields():
string[]
Returns the entity fields specified as result fields. An empty array is returned if no entity fields were specified. The result fields parameter limits the information included in an index search result to a specified list of fields. If no result fields are specified, all possible fields are included in the result.
Returns
string[]The names of the entity fields specified as result fields.
getResultIndexFields
getResultIndexFields():
string[]
Returns the index fields specified as result fields. An empty array is returned if no entity fields were specified. The result fields parameter limits the information included in an index search result to a specified list of fields. If no result fields are specified, all possible fields are included in the result.
Returns
string[]The names of the index fields specified as result fields.
getRows
getRows():
number
Returns
numberThe maximum number of documents returned by the result, null if not specified.
getSearchFields
getSearchFields():
string[]
Returns a list of entity fields whose corresponding index fields are searched. If no search fields are specified, all fields are searched. An empty array is returned if no entity fields were specified.
Returns
string[]The names of the entity fields to be searched.
getSearchIndexFields
getSearchIndexFields():
string[]
Returns the list of index fields to be searched. If no search fields are specified, all fields are searched. An empty array is returned if no search fields were specified.
Returns
string[]A List of the specified index fields to be searched.
getStart
getStart():
number
Returns
numberThe start offset for the result set. null if not specified.
getSubGroupsByEntity
getSubGroupsByEntity(
pEntity):string[]
Returns a list of the specified subgroups used to filter results for the given entity's index group. If no subgroups are specified for the entity an empty array is returned. NOTE: The list does not contain the subgroups that were specified via the corresponding index group.
Parameters
string | number | booleanThe name of the entity whose index group the subgroups belong to.
Returns
string[]all specified subgroups of the given entity's index group, which are filtered during the search.
getSubGroupsByIndexGroup
getSubGroupsByIndexGroup(
pIndexGroup):string[]
Returns a list of the specified subgroups used to filter results for the given index group. If no subgroups are specified for the index group an empty array is returned. NOTE: The list does not contain the subgroups that were specified via the corresponding entity.
Parameters
string | number | booleanThe name of the index groups to which the subgroups belong.
Returns
string[]all specified subgroups of the given index group, which are filtered during the search.
getTagResultLimit
getTagResultLimit():
number
Returns the maximum number of returned tags for the overall result for global tags (result.TAGS). Default is NULL, or no restriction.
Results for tags are always returned according to the total occurrence in the result of the search. A restriction to e.g. 10 tags thus returns the 10 most frequent tags in the search result.
Returns
numberthe defined limit of tags contained in the result, or NULL if no limit is set.
isApplyKeywordBoost
isApplyKeywordBoost():
boolean
Flag that specifies if the automatic boost for index fields with the isKeyword property should be used. If not set, null is returned and the implicit default true is used, so the keyword boost is applied.
Returns
booleanThe specified flag value, or null if not set.
isApplyLeadingWildcards
isApplyLeadingWildcards():
boolean
Flag, which adds a leading wildcard * to all terms of the main pattern before the search. If set to true, leading wildcards are added. E.g. 'foo bar' is converted to '*foo *bar'. If not set, null is returned and the implicit default false is used, so no wildcards are added. NOTE: It is best not to use this feature when using a pattern generated with an IndexPatternConfig or FilterJson as it modifies the pattern previously generated, which can result in an incorrect or broken pattern.
Returns
booleanThe specified flag value, or null if not set.
isApplyTrailingWildcards
isApplyTrailingWildcards():
boolean
Flag, which adds a trailing wildcard * to all terms of the main pattern before the search. If set to true, trailing wildcards are added. E.g. 'foo bar' is converted to 'foo* bar*'. If not set, null is returned and the implicit default false is used, so no wildcards are added. NOTE: It is best not to use this feature when using a pattern generated with an IndexPatternConfig or FilterJson as it modifies the pattern previously generated, which can result in an incorrect or broken pattern.
Returns
booleanThe specified flag value, or null if not set.
isAutomaticEscape
isAutomaticEscape():
boolean
Flag, which enables a pre-parser that tries to remove all syntax characters from the main pattern that can cause the search to fail. The pre-parser tries to preserve the pattern's original syntax. Syntax Characters: + - invalid input: '&' | ! ( ) { } [ ] ^ " ~ * ? : / If set to true, auto escaping is enabled. If not set, null is returned and the implicit default false is used, so no auto escaping is applied. E.g. the pattern '-foo + bar: OR field:foo-bar' results in the escaped pattern '-foo \+ bar\: OR field:foo\-bar'. NOTE: It is best not to use this feature when using a pattern generated with an IndexPatternConfig or FilterJson as it modifies the pattern previously generated, which can result in an incorrect or broken pattern.
Returns
booleanThe specified flag value, or null if not set.
isDisablePatternExtension
isDisablePatternExtension():
boolean
Flag that specifies that the filter patterns of the patternExtensions of the searched index groups should be applied to this search request. If set to true, the patternExtensions are ignored. If not set, null is returned and the implicit default false is used, so the pattenExtensions are applied. The pattern extensions are defined in the corresponding IndexRecordContainer of each index group. When using the legacy configuration the global process indexsearch_patternextension is used.
Returns
booleanThe specified flag value, or null if not set.
isEnableIndexGroupResult
isEnableIndexGroupResult():
boolean
Flag that specifies if the IndexGroupResult should be calculated for this search request. The IndexGroupResult contains a number of hits per index group. If not set, null is returned and the implicit default true is used, so the IndexGroupResult is calculated.
Returns
booleanThe specified flag value, or null if not set.
isSplitOnWhitespaces
isSplitOnWhitespaces():
boolean
Flag that specifies if text analysis is invoked separately for each individual whitespace-separated term. The default is true. If set to false whitespace-separated term sequences will be provided to text analysis in one shot, enabling proper function of analysis filters that operate over term sequences, e.g., multi-word synonyms and shingles. If not set, null is returned and the implicit default true is used, so the terms are invoked separately. NOTE In most cases, deactivation is only helpful when searching in a single index field, since all search terms must be contained in at least one of the index fields searched in order to count as hit.
Returns
booleanThe specified flag value, or null if not set.
isTagResultEnabled
isTagResultEnabled():
boolean
Flag which specifies whether a result for entire global tags of the search should be included in the result.
This is then included in the result under the name 'TAGS'. Default is false.
Returns
booleantrue if the tag result should be included.
setApplyKeywordBoost
setApplyKeywordBoost(
pApplyKeywordBoost):IndexQuery
Specifies whether automatic boost for index fields with the isKeyword property should be used. The default is true.
Parameters
booleantrue to enable the keyword boost. false to disable the boost.
Returns
IndexQueryindexQuery
setApplyLeadingWildcards
setApplyLeadingWildcards(
pApplyLeadingWildcards):IndexQuery
If set to true, a leading wildcard * is added to all terms of the main pattern before the search. E.g. 'foo bar' is converted to '*foo *bar'. The default is false, so no wildcards are added. NOTE: It is best not to use this feature when using a pattern generated with an IndexPatternConfig or FilterJson as it modifies the pattern previously generated, which can result in an incorrect or broken pattern.
Parameters
booleantrue if leading wildcards should be applied to the main pattern.
Returns
IndexQueryindexQuery
setApplyTrailingWildcards
setApplyTrailingWildcards(
pApplyTrailingWildcards):IndexQuery
If set to true, a trailing wildcard * is added to all terms of the main pattern before the search. E.g. 'foo bar' is converted to 'foo* bar*'. The default is false, so no wildcards are added. NOTE: It is best not to use this feature when using a pattern generated with an IndexPatternConfig or FilterJson as it modifies the pattern previously generated, which can result in an incorrect or broken pattern.
Parameters
booleantrue if trailing wildcards should be applied to the main pattern.
Returns
IndexQueryindexQuery
setAutomaticEscape
setAutomaticEscape(
pAutomaticEscape):IndexQuery
If true, a pre-parser tries to remove all syntax characters from the main pattern that can cause the search to fail. The pre-parser tries to preserve the pattern's original syntax. Default is false. Syntax Characters: + - invalid input: '&' | ! ( ) { } [ ] ^ " ~ * ? : / E.g. the pattern '-foo + bar: OR field:foo-bar' results in the escaped pattern '-foo \+ bar\: OR field:foo\-bar'. NOTE: It is best not to use this feature when using a pattern generated with an IndexPatternConfig or FilterJson as it modifies the pattern previously generated, which can result in an incorrect or broken pattern.
Parameters
booleantrue if the pattern should be escaped before search.
Returns
IndexQueryindexQuery
setAutomaticEscapeExcludedSigns
setAutomaticEscapeExcludedSigns(
pAutomaticEscapesExcludedSigns):IndexQuery
Specifies the syntax characters as a string that are excluded by the auto escape feature. If not specified all syntax characters are escaped. Syntax Characters: + - invalid input: '&' | ! ( ) { } [ ] ^ " ~ * ? : / Example which uses the auto escape feature and preserves the wildcards defined in the pattern.
Parameters
string | number | booleanA single string containing the excluded syntax characters.
Returns
IndexQueryindexQuery
Example
import("system.indexsearch");
var indexQuery = indexsearch.createIndexQuery();
// This example defines a pattern containing some invalid syntax characters.
// Auto escaping is enabled in order to escape the invalid characters before search.
// The wildcards in the pattern should be preserved so they are excluded from the auto escape.
indexQuery.setPattern("f?o - *bar!") // Defines the invalid pattern.
.setAutomaticEscape(true) // Enables auto escaping.
.setAutomaticEscapeExcludedSigns("*?"); // Excludes the wildcard characters.
// This results in the pattern 'f?o \- *bar\!'
var res = indexsearch.searchIndex(indexQuery)
setDefaultOperator
setDefaultOperator(
pDefaultOperator):IndexQuery
Sets the default operator used by the main pattern. Possible values are OR (indexsearch.OPERATOR_OR) and AND (indexsearch.OPERATOR_AND). The default is OR. The standard operator specifies how the search terms of a pattern are handled by the parser if no explicit operator has been specified for them.
-
OR: The pattern '
foo bar' is treated as 'foo OR bar'. -
AND: The pattern '
foo bar' is treated as 'foo AND bar'.
NOTE: This only effects the main pattern. filter patterns always use OR as the default operator. The patterns generated with an IndexPatternConfiguration work best with the default operator OR
Parameters
string | number | booleanThe default operator for the main pattern.
Returns
IndexQueryindexQuery
setDisablePatternExtension
setDisablePatternExtension(
pDisablePatternExtension):IndexQuery
Specifies whether the filter patterns of the patternExtensions of the searched index groups should be applied to this search request. Default is false, so the pattenExtensions are applied. The pattern extensions are defined in the corresponding IndexRecordContainer of each index group. When using the legacy configuration the global process indexsearch_patternextension is used.
Parameters
booleantrue if the patten extension(s) are ignored.
Returns
IndexQueryindexQuery
setEnableIndexGroupResult
setEnableIndexGroupResult(
pEnableIndexGroupResult):IndexQuery
Specifies if the IndexGroupResult should be calculated for this search request. The default is true The IndexGroupResult contains a number of hits per index group.
Parameters
booleantrue if the IndexGroupResult should be calculated.
Returns
IndexQueryindexQuery
setEntities
setEntities(
pEntities):IndexQuery
Sets the index groups to the search by their defining entity. Entities previously defined are overwritten. The actual index groups are looked up for each defined entity during the searchIndex call. The entity must contain an active IndexRecordContainer. Search will fail if an index group cannot be found for any of the specified entities. The search is limited to the index groups defined in the index query. If no index groups are specified, all groups are searched.
Parameters
string[]The names of the entities containing the actual index groups.
Returns
IndexQueryIndexQuery
setExcludedTags
setExcludedTags(
pExcludedTags):IndexQuery
Sets all global tags which must not be contained in the elements of the result (hits).
Excluded tags always use the AND operator for filtering.
NOTE: All previous defined values are overridden.
Parameters
string[]Returns
IndexQueryindexQuery
setIncludedTags
setIncludedTags(
pIncludedTags):IndexQuery
Sets global tags which must be contained in the elements of the result (hits).
How the tags are filtered depends on the selected operator. Default is AND.
NOTE: All previous defined values are overridden.
Parameters
string[]Returns
IndexQueryindexQuery
setIncludedTagsOperator
setIncludedTagsOperator(
pIncludedTagsOperator):IndexQuery
Sets the operator used for filtering the global tags included in the search. Default is AND.
NOTE: Valid values are 'OR' (indexsearch.OPERATOR_OR) or 'AND' (indexsearch.OPERATOR_AND). All other values are ignored.
Parameters
string | number | booleanthe operator as string.
Returns
IndexQueryindexQuery
setIndexGroups
setIndexGroups(
pGroups):IndexQuery
Sets the index groups to the search by name. Groups previously defined are overwritten. The search is limited to the index groups defined in the index query. If no index groups are specified, all groups are searched.
Parameters
string[]The names of the index groups.
Returns
IndexQueryIndexQuery
setLanguageSearchMode
setLanguageSearchMode(
pName):IndexQuery
Specifies which locales the index search uses.
Parameters
string | number | booleanthe mode or null
Returns
IndexQueryindexQuery
Throws
AditoIllegalArgumentException
setLocale
setLocale(
pLocale):IndexQuery
Flag that specifies the locale that is to be used for search queries.
Parameters
string | number | booleanthe locale or null
Returns
IndexQueryindexQuery
Throws
AditoIllegalArgumentException
setPattern
setPattern(
pPattern):IndexQuery
Sets the main pattern for the search. If not set, the query's main pattern is treated as a "search all" pattern (*:*). Example: indexsearch.createIndexQuery().setPattern("foo* AND bar*")
Parameters
string | number | booleanthe search pattern as string.
Returns
IndexQueryIndexQuery
setResultFields
setResultFields(
pResultFields):IndexQuery
Sets and defines the index fields contained in the result documents based on the specified entity fields. Entity fields previously defined are overwritten. The result fields parameter limits the information included in an index search result to a specified list of fields. The names of the entity fields 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 fields are looked up when calling searchIndex. The search fails if an index field cannot be determined for an entity field. To use an index field as a result field, the stored property in the corresponding IndexRecordField must be set to true. If no result fields are specified, all possible fields are returned.
Parameters
string[]The names of the entity fields.
Returns
IndexQueryIndexQuery
setResultIndexFields
setResultIndexFields(
pResultFields):IndexQuery
Sets and defines the index fields contained in the result documents. Index fields previously defined are overwritten. The result fields parameter limits the information included in an index search result to a specified list of fields. To use an index field as a result field, the stored property in the corresponding IndexRecordField must be set to true. If no result fields are specified, all possible fields are returned.
Parameters
string[]The index fields contained in the result documents.
Returns
IndexQueryIndexQuery
setRows
setRows(
pRows):IndexQuery
The rows parameter specifies the maximum number of documents to be returned from the complete result set. This parameter can be used to paginate results from a query. The default value is defined in the project preferences over the property indexsearchDefaultResultCount.
Parameters
numberThe maximum number of documents to be returned
Returns
IndexQueryIndexQuery
setSearchFields
setSearchFields(
pFields):IndexQuery
Sets and defines the entity fields whose corresponding index field is to be searched. Entity fields previously defined are overwritten. The names of the entity fields 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 fields are looked up when calling searchIndex. The search fails if an index field cannot be determined for an entity field. To use an index field as a search field, the indexed property in the corresponding IndexRecordField must be set to true. If no search fields are specified, all fields are searched.
Parameters
string[]the names of the entity fields to be searched.
Returns
IndexQueryIndexQuery
setSearchIndexFields
setSearchIndexFields(
pFields):IndexQuery
Sets and defines index fields to be searched. Index fields previously defined are overwritten. To use an index field as a search field, the indexed property in the corresponding IndexRecordField must be set to true. If no search fields are specified, all fields are searched.
Parameters
string[]the names of the index fields to be searched.
Returns
IndexQueryIndexQuery
setSplitOnWhitespaces
setSplitOnWhitespaces(
pSplitOnWhitespaces):IndexQuery
Split on whitespace. If set to true, text analysis is invoked separately for each individual whitespace-separated term. The default is true. If set to false whitespace-separated term sequences will be provided to text analysis in one shot, enabling proper function of analysis filters that operate over term sequences, e.g., multi-word synonyms and shingles. NOTE In most cases, deactivation is only helpful when searching in a single index field, since all search terms must be contained in at least one of the index fields searched in order to count as hit.
Parameters
booleantrue to enable and false to disable the split on whitespace option.
Returns
IndexQueryindexQuery
setStart
setStart(
pStart):IndexQuery
When specified, the start parameter specifies a start offset for the result set and instructs the index search to begin displaying results from this offset. The default value is 0. In other words, by default, The index search returns results without an offset, beginning where the results themselves begin. Setting the start parameter to some other number, such as 3, causes the index search to skip over the preceding rows and start at the document identified by the offset. This parameter can be used to support paging.
Parameters
numberThe start offset.
Returns
IndexQueryIndexQuery
setSubGroupsByEntity
setSubGroupsByEntity(
pEntity,pSubGroups):IndexQuery
Sets the subgroups of the given entity's index group to the search. Subgroups previously defined for the given entity are overwritten. The search for the given entity's index group is limited to the subgroups defined in the index query. If the entity's index group of the specified subgroups is excluded from search, all defined subgroups of that index group are ignored.
Parameters
string | number | booleanThe names of the entity.
string[]The subgroups used to filter results for the given entity's index group.
Returns
IndexQueryIndexQuery
setSubGroupsByIndexGroup
setSubGroupsByIndexGroup(
pIndexGroup,pSubGroups):IndexQuery
Sets the subgroups of the given index group to the search. Subgroups previously defined for the given index group are overwritten. The search for the given index group is limited to the subgroups defined in the index query. If the index group of the specified subgroups is excluded from search, all defined subgroups of that index group are ignored.
Parameters
string | number | booleanThe names of the index group.
string[]The subgroups used to filter results for the given index group.
Returns
IndexQueryIndexQuery
setTagResultEnabled
setTagResultEnabled(
pTagResultEnabled):IndexQuery
Specifies whether a result for the entire global tags of the search should be included in the result. This is then included in the result under the name 'TAGS'.
Parameters
booleantrue to include the tag result.
Returns
IndexQueryindexQuery
setTagResultLimit
setTagResultLimit(
pTagLimit):IndexQuery
Sets the limit for the maximum number of returned global tags contained in the overall result for global tags (result.TAGS) in the search. Default is NULL, or no restriction.
Results for tags are always returned according to the total occurrence in the result of the search. A restriction to e.g. 10 tags thus returns the 10 most frequent tags in the search result.
Parameters
numberthe specified limit, or NULL for no limitation.
Returns
IndexQueryindexQuery
setUseRankedSearch
setUseRankedSearch(
pUseRankedSearch):IndexQuery
Flag that specifies if the ranked search mechanism of the global user search should be used. the default is false.
Parameters
booleantrue to enable the ranked search option. false to disable the option.
Returns
IndexQueryindexQuery
Example
<code>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.
</code>