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 (opens new window) (check here the mapping capabilities of ElasticSearch (opens new window)).
This method will only update the mapping if the collection already exists.
Arguments #
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 (opens new window) |
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:
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 #
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();
Edit this page on Github (opens new window)