SDK
SDK Java v3.x
2

This SDK is deprecated. We recommend to use the Kuzzle SDK-JVM.
A migration guide is available here

create #

Creates a new collection in Kuzzle via the persistence engine, in the provided index.

You can also provide an optional data mapping that allows you to exploit the full capabilities of our persistent data storage layer, ElasticSearch (check here the mapping capabilities of ElasticSearch).

This method will only update the mapping if the collection already exists.



Arguments #

Copied to clipboard!
public CompletableFuture<Void> create(
      final String index,
      final String collection,
      final ConcurrentHashMap<String, Object> mapping)
throws NotConnectedException, InternalException

public CompletableFuture<Void> create(
      final String index,
      final String collection)
throws NotConnectedException, InternalException
Arguments Type Description
index
String
Index
collection
String
Collection
mapping
ConcurrentHashMap<String, Object>
Describes the data mapping to associate to the new collection, using Elasticsearch mapping format

mapping #

A ConcurrentHashMap<String, Object> representing the data mapping of the collection.

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

Copied to clipboard!
  ConcurrentHashMap<String, Object> mapping = new ConcurrentHashMap<>();
  ConcurrentHashMap<String, Object> properties = new ConcurrentHashMap<>();
  ConcurrentHashMap<String, Object> field = new ConcurrentHashMap<>();

  field.put("type", "keyword");
  properties.put("field", field);
  mapping.put("properties", properties);

More information about database mappings here.

Usage #

Copied to clipboard!
ConcurrentHashMap<String, Object> mapping = new ConcurrentHashMap<>();
ConcurrentHashMap<String, Object> properties = new ConcurrentHashMap<>();
ConcurrentHashMap<String, Object> license = new ConcurrentHashMap<>();
license.put("type", "keyword");
properties.put("license", license);
mapping.put("properties", properties);
kuzzle.getCollectionController().create("nyc-open-data", "yellow-taxi", mapping)
  .get();