search() #

Searches documents.

Arguments #

search(query: JSONObject, options?: JSONObject): Promise<any>;

ArgumentsTypeDescription
query
JSONObject
Search query, using Elasticsearch query format
options
JSONObject
Optional arguments

options #

The options argument accepts the following parameters:

OptionsTypeDescription
from
integer
Paginates search results by defining the offset from the first result you want to fetch. Usually used with the size option
scroll
string
Creates a forward-only result cursor. This option must be set with a time duration, at the end of which the cursor is destroyed.
If set, a cursor identifier named scrollId is returned in the results. The repository has no scroll method to move this cursor forward: paginate with from and size instead
size
integer
Sets the maximum number of documents returned per result page

Return #

The search function returns a promise resolving to a search result object, with the following properties:

FieldTypeDescription
aggregations
JSONObject
Aggregations results, if the query requested aggregations
hits
any[]
Found documents. If a ObjectConstructor argument was provided to the repository constructor, then each hit is an instance of that class instead of a raw object
total
integer
Total number of found documents. Can be greater than the number of documents returned in this result set
scrollId
string
Cursor identifier, only returned if the scroll option was set