search()
#
Searches documents.
Arguments #
search(query: JSONObject, options?: JSONObject): Promise<any>;
Arguments | Type | Description |
---|---|---|
query | JSONObject | Search query, using Elasticsearch query format |
options | JSONObject | Optional arguments |
options #
The options
argument accepts the following parameters:
Options | Type | Description |
---|---|---|
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:
Field | Type | Description |
---|---|---|
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 |
Edit this page on Github(opens new window)