SDK
SDK C# v2.x
2

updateMapping #

Updates the collection mappings.

Arguments #

Copied to clipboard!
public async Task UpdateMappingAsync(
        string index,
        string collection,
        JObject mappings);
Argument Type Description
index
string
Index name
collection
string
Collection name
mappings
JObject
JObject representing the collection data mapping

mapping #

A JObject representing the collection data mapping.

  • dynamic: dynamic mapping policy for new fields. Allowed values: true (default), false, strict
  • _meta: collection additional metadata stored next to the collection
  • properties: object describing the data mapping to associate to the new collection, using [Elasticsearch types definitions format](object describing the data mapping to associate to the new collection, using)
Copied to clipboard!
{
  "dynamic": "[true|false|strict]",
  "_meta": {
    "field": "value"
  },
  "properties": {
    "field1": {
      "type": "integer"
    },
    "field2": {
      "type": "keyword"
    },
    "field3": {
      "type":   "date",
      "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
    }
  }
}

More information about database mappings here.

Usage #

Copied to clipboard!
try {
  JObject mappings = JObject.Parse(@"{
    properties: {
      plate: { 
        type: 'keyword'
      }
    }
  }");
  await kuzzle.Collection.UpdateMappingAsync("nyc-open-data", "yellow-taxi", mappings);
  Console.WriteLine("Mapping successfully updated");
} catch (Exception e) {
  Console.WriteLine(e);
}