This repository was archived by the owner on Sep 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Add document:mCreate #64
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
68e0d06
document:mCreate
y-abs a92c048
fix and doc
y-abs df91638
doc
y-abs 7f70801
Merge branch '3-dev' into KZL-1350-document-mCreate
y-abs 1bf539f
requested changes
y-abs 3db75e5
add ArrayList to default template
y-abs 814f808
Merge branch 'KZL-1350-document-mCreate' of github.com:kuzzleio/sdk-j…
y-abs 08aff15
template useless import
y-abs 4786ff7
@aschen requested change
y-abs b1f37ab
template print array
y-abs f2d2208
doc
y-abs 0948b71
conflict [ci skip]
y-abs b8d0fa9
Merge branch '3-dev' into KZL-1350-document-mCreate
y-abs 62f6fc5
doc
y-abs f81f44a
nit
y-abs fbc2232
conflict [ci skip]
y-abs 49a0997
Merge branch 'KZL-1350-document-mCreate' of github.com:kuzzleio/sdk-j…
y-abs 6e398ba
conflict [ci skip]
y-abs e8c1be3
Merge branch '3-dev' into KZL-1350-document-mCreate
y-abs e42224b
conflict
y-abs c75b8da
Merge branch '3-dev' into KZL-1350-document-mCreate
scottinet 4e8a0b3
Wrapped code
scottinet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| --- | ||
| code: true | ||
| type: page | ||
| title: mCreate | ||
| description: Creates multiple documents | ||
| --- | ||
|
|
||
| # mCreate | ||
|
|
||
| Creates multiple documents. | ||
|
|
||
| --- | ||
|
|
||
| ## Arguments | ||
|
|
||
| ```java | ||
| public CompletableFuture<ConcurrentHashMap<String, ArrayList<Object>>> mCreate( | ||
| final String index, | ||
| final String collection, | ||
| final ArrayList<ConcurrentHashMap<String, Object>> documents) | ||
| throws NotConnectedException, InternalException | ||
|
|
||
| public CompletableFuture<ConcurrentHashMap<String, ArrayList<Object>>> mCreate( | ||
| final String index, | ||
| final String collection, | ||
| final ArrayList<ConcurrentHashMap<String, Object>> documents, | ||
| final Boolean waitForRefresh) | ||
| throws NotConnectedException, InternalException | ||
| ``` | ||
|
|
||
| | Arguments | Type | Description | | ||
| | ------------------ | ------------------------------------------------------- | --------------------------------- | | ||
| | `index` | <pre>String</pre> | Index | | ||
| | `collection` | <pre>String</pre> | Collection | | ||
| | `documents` | <pre>ArrayList<ConcurrentHashMap<String, Object>></pre> | ArrayList containing the documents to create | | ||
| | `waitForRefresh` | <pre>Boolean</pre> | If set to `true`, Kuzzle will wait for the persistence layer to finish indexing | | ||
|
|
||
| --- | ||
|
|
||
| ### documents | ||
|
|
||
| Each document has the following properties: | ||
|
|
||
| | Arguments | Type | Description | | ||
| | ------------------ | -------------------------------------------- | --------------------------------- | | ||
| | `_id` | <pre>String</pre> | Optional document ID. Will be auto-generated if not defined. | | ||
| | `body` | <pre>ConcurrentHashMap<String, Object></pre> | Document body | | ||
|
|
||
| ## Return | ||
|
|
||
| A `ConcurrentHashMap<String, ArrayList<Object>>` which has a `successes` and `errors` `ArrayList<Object>`: | ||
| Each created document is an object of the `successes` array with the following properties: | ||
|
|
||
| | Property | Type | Description | | ||
| |------------- |--------------------------------------------- |--------------------------------- | | ||
| | `_source` | <pre>ConcurrentHashMap<String, Object></pre> | Created document | | ||
| | `_id` | <pre>String</pre> | ID of the newly created document | | ||
| | `_version` | <pre>Integer</pre> | Version of the document in the persistent data storage | | ||
|
|
||
| Each errored document is an object of the `errors` array with the following properties: | ||
|
|
||
| | Property | Type | Description | | ||
| |------------- |--------------------------------------------- |--------------------------------- | | ||
| | `document` | <pre>ConcurrentHashMap<String, Object></pre> | Document that causes the error | | ||
| | `status` | <pre>Integer</pre> | HTTP error status | | ||
| | `reason` | <pre>String</pre> | Human readable reason | | ||
|
|
||
| ## Usage | ||
|
|
||
| <<< ./snippets/m-create.java | ||
54 changes: 54 additions & 0 deletions
54
doc/3/controllers/document/m-create/snippets/m-create.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| ConcurrentHashMap<String, Object> document1 = new ConcurrentHashMap<>(); | ||
| ConcurrentHashMap<String, Object> document2 = new ConcurrentHashMap<>(); | ||
| ConcurrentHashMap<String, Object> body = new ConcurrentHashMap<>(); | ||
| ConcurrentHashMap<String, Object> body2 = new ConcurrentHashMap<>(); | ||
|
|
||
| body.put("Agent", "Smith"); | ||
| body2.put("Gordon", "Freeman"); | ||
|
|
||
| document1.put("_id", "some-id"); | ||
| document1.put("body", body); | ||
|
|
||
| document2.put("_id", "some-id2"); | ||
| document2.put("body", body2); | ||
|
|
||
| final ArrayList<ConcurrentHashMap<String, Object>> documents = new ArrayList<>(); | ||
| documents.add(document1); | ||
| documents.add(document2); | ||
|
|
||
| ConcurrentHashMap<String, ArrayList<Object>> result = kuzzle | ||
| .getDocumentController() | ||
| .mCreate("nyc-open-data", "yellow-taxi", documents) | ||
| .get(); | ||
|
|
||
| /* | ||
| result = | ||
| { | ||
| successes= | ||
| [ | ||
| { | ||
| result=created, | ||
| _source= | ||
| { | ||
| Agent=Smith, | ||
| _kuzzle_info={createdAt=1582892842099, author=-1} | ||
| }, | ||
| _id=some-id, | ||
| _version=1, | ||
| status=201 | ||
| }, | ||
| { | ||
| result=created, | ||
| _source= | ||
| { | ||
| Gordon=Freeman, | ||
| _kuzzle_info={createdAt=1582892842099, author=-1} | ||
| }, | ||
| _id=some-id2, | ||
| _version=1, | ||
| status=201 | ||
| } | ||
| ], | ||
| errors=[] | ||
| } | ||
| */ |
12 changes: 12 additions & 0 deletions
12
doc/3/controllers/document/m-create/snippets/m-create.test.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| name: document#mCreate | ||
| description: Creates multiple documents | ||
| hooks: | ||
| before: | | ||
| curl -XDELETE kuzzle:7512/nyc-open-data | ||
| curl -XPOST kuzzle:7512/nyc-open-data/_create | ||
| curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi | ||
| after: | ||
| template: print-result-array | ||
| expected: | ||
| - "id=some-id, _version=1, status=201" | ||
| - "id=some-id2, _version=1, status=201" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.