BackendStorage #
Available since 2.8.0
The BackendStorage
class allows to interact directly with Elasticsearch.
It is accessible from the Backend.storage property.
See the Data Storage guide.
storageClient
#
Type | Description | get / set |
---|---|---|
Client | Lazily instantiated Elasticsearch Node.js client | get |
Usage #
const esRequest = {
body: {
name: 'Aschen',
age: 27
},
index: '&nyc-open-data.yellow-taxi',
op_type: 'create'
}
await app.storage.client.index(esRequest)
StorageClient
#
Type | Description | get / set |
---|---|---|
new (clientConfig?: any) => Client | Storage client constructor | get |
By default, the instantiated client uses the same configuration than the one used by Kuzzle.
It's possible to overload the client configuration by passing the clientConfig
argument to the constructor.
Usage #
const esRequest = {
body: {
name: 'Aschen',
age: 27
},
index: '&nyc-open-data.yellow-taxi',
op_type: 'create'
}
// Instantiate and use a new client
const storageClient = new app.storage.Client()
await storageClient.index(esRequest)
Edit this page on Github(opens new window)