SDK
SDK Golang v1.x
1

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 #

Copied to clipboard!
UpdateMapping(index string, collection string, mapping json.RawMessage, options types.QueryOptions) error
Arguments Type Description
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:

Copied to clipboard!
{
  "properties": {
    "field1": { "type": "text" },
    "field2": {
      "properties": {
        "nestedField": { "type": "keyword" }
      }
    }
  }
}

More informations about database mappings here.

options #

Additional query options

Property Type Description Default
queuable
bool
Make this request queuable or not true

Return #

Return an error if something went wrong.

Usage #

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