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.


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
timeout
number

(-1)
Time (in ms) during which a request will still be waited to be resolved. Set it -1 if you want to wait indefinitely
triggerEvents
boolean

(false)
If set to true, will trigger events even if using Embeded SDK. You should always ensure that your events/pipes does not create an infinite loop.
Available since Kuzzle 2.31.0

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);
}