SDK
SDK Javascript v7.x
2

# updateMapping

Available since Kuzzle 1.7.1
Deprecated since Kuzzle 2.1.0

Use collection:update instead.

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.


Copied to clipboard!
updateMapping(index, collection, mapping, [options]);

Arguments Type Description
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:

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

More informations about database mappings here.

# options

Additional query options

Property Type
(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

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