When executing a search, a
SearchParameter instance must be passed to define the general conditions of the search.
For simple use cases
SearchParameter.DEFAULT can be used:
The attributes of
SearchParameter affect various aspects of the search execution and the search result.
The different parameter attributes can be defined via the
|maxResults||Maximum number of results||10000|
|maxTrackTotalHits||Maximum number of total hits to track. If exceeded, tracking will be stopped and total hits count will be marked as not exact.||Elasticsearch server setting|
|pageSize||Pagination page size||100|
|pageIndex||Pagination page index (starts with 1)||1|
|sortOptions||Result sort options (in descending priority)||unsorted|
|language||Language for multilingual fields||language of user account|
|fieldsToResolve||Names of fields to be resolved in search result||all fields|
|aggregations||Aggregations of fields to build facets on||no aggregations|
|optimizeExpressions||Should expressions be optimized?||true|
Sets the maximum number of results that can be paginated (default = 10000).
Sets the maximum number of total hits to track. If this number is exceeded by the number of current search hits, tracking will be stopped and the total hits count will be marked as not exact.
Sets the pagination page size (default =
The default page size and the default max page size can be overridden in
Sets the pagination page index (starts with 1).
To get the next (or any other) page of a search result, the previous search must be executed again with the new page index.
A pagination sample can be found here.
Sets the result sort options (in descending priority).
The following example sorts first by
id in descending order, then by
title in ascending order:
Fields can only be sorted if they have been configured as
sortable in the corresponding field configuration.
Search results may be sorted by the relevance of the search hits:
The relevance of a search hit is calculated by Elasticsearch’s internal scoring algorithm.
A sort by relevance sample can be found here.
To sort by fields which contain multiple values (arrays), an array mode may be set:
||Use the lowest value.|
||Use the highest value.|
||Use the sum of all values. May only be used on number based array fields.|
||Use the average of all values. May only be used for for number based array fields.|
||Use the median of all values. May only be used for number based array fields.|
A sort by array mode sample can be found here.
Sets the request language for multilingual fields (default = language of user account). This affects searching, sorting and faceting.
A prerequisite is that the query refers to a field that has been defined as
A multilingual search sample can be found here.
Sets the names of the fields to be resolved in the search result (default = all fields).
If an index document has many fields and not all fields are required in the result, the fields to be resolved (returned) can be specified:
Sets the aggregations of fields to build facets on (default = no aggregations).
A prerequisite is that the fields have been defined as
Sets if expressions should be optimized (default =
true, the passed expression is optimized internally and if necessary the complexity is reduced.
For debugging it can sometimes be helpful to set
Expression optimizer can generally be enabled/disabled via
elasticsearch.properties (default =
Expression optimizer is disabled in
elasticsearch.properties, the search parameter
optimizeExpressions is ignored.