SDK
SDK Jvm v1.x
2

update #

Available since Kuzzle 2.1.0

You can define the collection dynamic mappings policy by setting the dynamic field to the desired value.

You can define collection additional metadata within the _meta root field.

Available since Kuzzle 2.2.0

You can also provide Elasticsearch index settings when creating a new collection.


:::: tabs ::: tab Java

Arguments #

public CompletableFuture<Map<String, Object>> update(
      final String index,
      final String collection,
      final Map<String, Object> definition)

ArgumentsTypeDescription
index
String
Index name
collection
String
Collection name
definition
Map<String, Object>
Describes the collection mappings and the ES index settings

definition #

An object containing:

{
  "mappings"={
    "properties"={
      "field1"={ "type"="text" },
      "field2"={
        "properties"={
          "nestedField"={ "type": "keyword" }
        }
      }
    }    
  },
  "settings"={
    // index settings (e.g. analyzers)
  }
};

Usage #

Map<String, Object> definition = new HashMap<>();
Map<String, Object> properties = new HashMap<>();
Map<String, Object> _meta = new HashMap<>();
Map<String, Object> plate = new HashMap<>();
plate.put("type", "keyword");
_meta.put("area", "Panipokhari");
properties.put("plate", plate);
definition.put("dynamic", false);
definition.put("_meta", _meta);
definition.put("properties", properties);
kuzzle
  .getCollectionController()
  .update("nyc-open-data", "yellow-taxi", definition)
  .get();
System.out.println("Success");

::: ::: tab Kotlin

Arguments #

fun update(
    index: String,
    collection: String,
    definition: Map<String, Any?>
  ): CompletableFuture<Void>

ArgumentsTypeDescription
index
String
Index name
collection
String
Collection name
definition
Map<String, Any?>
Describes the collection mappings and the ES index settings

definition #

An object containing:

{
  "mappings"={
    "properties"={
      "field1"={ "type"="text" },
      "field2"={
        "properties"={
          "nestedField"={ "type": "keyword" }
        }
      }
    }    
  },
  "settings"={
    // index settings (e.g. analyzers)
  }
};

Usage #

val plate: Map<String, Any?> =
HashMap<String, Any?>().apply{
  put("type", "keyword")
}
val _meta: Map<String, Any?> =
HashMap<String, Any?>().apply{
  put("area", "Panipokhari")
}
val properties: Map<String, Any?> =
HashMap<String, Any?>().apply{
  put("plate", plate)
}
val definition: Map<String, Any?> =
HashMap<String, Any?>().apply{
  put("dynamic", false)
  put("_meta", _meta)
  put("properties", properties)
}
kuzzle
  .collectionController
  .update("nyc-open-data", "yellow-taxi", definition)
  .get();
print("Success");

::: ::::