Core
Framework v2.x
2

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 #

TypeDescriptionget / set
Client
Lazily instantiated Elasticsearch Node.js clientget

Usage #

const esRequest =  {
  body: {
    name: 'Aschen',
    age: 27
  },
  index: '&nyc-open-data.yellow-taxi',
  op_type: 'create'
}

await app.storage.client.index(esRequest)

StorageClient #

TypeDescriptionget / set
new (clientConfig?: any) => Client
Storage client constructorget

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)