search #
Available since 7.8.0
Searches for documents and returns a SearchResult containing realtime documents.
This method uses the Document.search method under the hood to retrieve documents.
Arguments #
search (index: string, collection: string, searchBody: JSONObject, options: JSONObject): Promise<RealtimeDocumentSearchResult>
Argument | Type | Description |
---|---|---|
index | string | Index name |
collection | string | Collection name |
searchBody | JSONObject | Search body |
options | JSONObject | Additional options |
Usage #
const observer = new Observer(sdk);
let result = await observer.search('nyc-open-data', 'yellow-taxi', {
query: { exists: 'licence' }
});
console.log(result);
/*
RealtimeDocumentSearchResult {
aggregations: undefined,
hits: [
RealtimeDocument {
_id: 'some-id',
_source: [Object],
deleted: false
},
RealtimeDocument {
_id: 'XaMyen0BDorKTmOQPm2u',
_source: [Object],
deleted: false
}
],
fetched: 2,
total: 2,
suggest: undefined
}
*/
Edit this page on Github(opens new window)