SDK
SDK Golang v2.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 #

Update the collection mapping. Mapping allow you to exploit the full capabilities of our persistent data storage layer, ElasticSearch (check here the mapping capabilities of ElasticSearch).

Arguments #

UpdateMapping(index string, collection string, mapping json.RawMessage, options types.QueryOptions) error
ArgumentsTypeDescription
index
string
Index name
collection
string
Collection name
mapping
json.RawMessage
Collection data mapping in JSON format
options
QueryOptions
Query options

mapping #

An string containing the JSON representation of the collection data mapping.

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

{
  "properties": {
    "field1": { "type": "text" },
    "field2": {
      "properties": {
        "nestedField": { "type": "keyword" }
      }
    }
  }
}

More informations about database mappings here.

options #

Additional query options

PropertyTypeDescriptionDefault
queuable
bool
Make this request queuable or nottrue

Return #

Return an error if something went wrong.

Usage #

mapping := json.RawMessage(`{"properties":{"plate": {"type": "keyword"}}}`)
err := kuzzle.Collection.UpdateMapping("nyc-open-data", "yellow-taxi", mapping, nil)
if err != nil {
  log.Fatal(err)
} else {
  fmt.Println("Success")
}