SDK
SDK Golang v3.x
2

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