Core
Framework v2.x
2

BackendStorage #

Available since 2.8.0
Experimental: non-backward compatible changes or removal may occur in any future release.

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 #

Copied to clipboard!
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 #

Copied to clipboard!
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)