Core
Framework v2.x
2

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. This cursor can then be moved forward using the scroll function
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
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