SDK
SDK Javascript v6.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

updateMapping #

Available since 1.7.1

You can define the collection dynamic mapping policy by setting the dynamic field to the desired value.

You can define collection additional metadata within the _meta root field.


updateMapping(index, collection, mapping, [options]);

ArgumentsTypeDescription
index
string
Index name
collection
string
Collection name
mapping
object
Describes the collection mapping
options
object
Query options

mapping #

An object representing the collection data mapping.

This object must have a root field properties that contain the mapping definition:

const mapping = {
  properties: {
    field1: { type: 'text' },
    field2: {
      properties: {
        nestedField: { type: 'keyword' }
      }
    }
  }
};

More informations about database mappings here.

options #

Additional query options

PropertyType
(default)
Description
queuable
boolean

(true)
If true, queues the request during downtime, until connected to Kuzzle again

Resolves #

Resolve if the collection is successfully updated.

Usage #

const mapping = {
  dynamic: 'false',
  _meta: {
    area: 'Panipokhari'
  },
  properties: {
    plate: { type: 'keyword' }
  }
};
try {
  await kuzzle.collection.updateMapping('nyc-open-data', 'yellow-taxi', mapping);
  console.log('Success');
} catch (error) {
  console.error(error.message);
}