-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add page about bulk:write and bulk:mwrite (#300)
## What does this PR do? Documents bulk:write and bulk:mWrite. See kuzzleio/kuzzle#1302 ### How should this be manually tested? - Step 1 : - Step 2 : - Step 3 : ... ### Other changes Add references to these methods in data validation, kuzzle metadata and real-time guides
- Loading branch information
Showing
4 changed files
with
264 additions
and
4 deletions.
There are no files selected for viewing
147 changes: 147 additions & 0 deletions
147
src/core/1/api/api-reference/controller-bulk/m-write/index.md
This file contains 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,147 @@ | ||
--- | ||
code: true | ||
type: page | ||
title: mWrite | ||
--- | ||
|
||
# mWrite | ||
|
||
<SinceBadge version="1.8.0" /> | ||
|
||
|
||
Create or replace multiple documents directly into the storage engine. | ||
|
||
This is a low level route intended to bypass Kuzzle actions on document creation, notably: | ||
- check [document validity](/core/1/guide/guides/essentials/data-validation), | ||
- add [kuzzle metadata](/core/1/guide/guides/essentials/document-metadata), | ||
- trigger [realtime notifications](/core/1/guide/guides/essentials/real-time) (unless asked otherwise) | ||
|
||
--- | ||
|
||
## Query Syntax | ||
|
||
### HTTP | ||
|
||
```http | ||
URL: http://kuzzle:7512/<index>/<collection>/_mWrite[?refresh=wait_for][¬ify] | ||
Method: POST | ||
Body: | ||
``` | ||
|
||
```js | ||
{ | ||
"documents": [ | ||
{ | ||
"_id": "<documentId>", | ||
"body": { | ||
// document content | ||
} | ||
}, | ||
{ | ||
"_id": "<anotherDocumentId>", | ||
"body": { | ||
// document content | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
|
||
### Other protocols | ||
|
||
```js | ||
{ | ||
"index": "<index>", | ||
"collection": "<collection>", | ||
"controller": "bulk", | ||
"action": "mWrite", | ||
|
||
"notify": "<boolean>", | ||
"body": { | ||
"documents": [ | ||
{ | ||
"_id": "<documentId>", | ||
"body": { | ||
// document content | ||
} | ||
}, | ||
{ | ||
"_id": "<anotherDocumentId>", | ||
"body": { | ||
// document content | ||
} | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
|
||
--- | ||
|
||
## Arguments | ||
|
||
- `collection`: data collection | ||
- `index`: data index | ||
|
||
### Optional: | ||
|
||
- `notify`: if set to true, Kuzzle will trigger realtime notifications | ||
- `refresh`: if set to `wait_for`, Kuzzle will not respond until the created/replaced documents are indexed | ||
|
||
--- | ||
|
||
## Body properties | ||
|
||
- `documents`: an array of object. Each object describes a document to create or replace, by exposing the following properties: | ||
- `_id`: document unique identifier | ||
- `body`: document content | ||
|
||
--- | ||
|
||
## Response | ||
|
||
Returns a `hits` array, containing the list of created documents, in the same order than the one provided in the query. | ||
|
||
Each created document is an object with the following properties: | ||
|
||
- `_id`: created document unique identifier | ||
- `_source`: document content | ||
- `_version`: version number of the document | ||
- `created`: a boolean telling whether a document is created | ||
|
||
If one or more document creations fail, the response status is set to `206`, and the `error` object contains a [partial error](/core/1/api/essentials/errors/#partialerror) error. | ||
|
||
### Example | ||
|
||
```javascript | ||
{ | ||
"status": 200, | ||
"error": null, | ||
"index": "<index>", | ||
"collection": "<collection>", | ||
"action": "mWrite", | ||
"controller": "bulk", | ||
"requestId": "<unique request identifier>", | ||
"result": { | ||
"hits": [ | ||
{ | ||
"_id": "<documentId>", | ||
"_source": { | ||
// document content | ||
}, | ||
"_version": 2, | ||
"created": false | ||
}, | ||
{ | ||
"_id": "<anotherDocumentId>", | ||
"_source": { | ||
// document content | ||
}, | ||
"_version": 1, | ||
"created": true | ||
} | ||
], | ||
"total": 2 | ||
} | ||
} | ||
``` |
101 changes: 101 additions & 0 deletions
101
src/core/1/api/api-reference/controller-bulk/write/index.md
This file contains 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,101 @@ | ||
--- | ||
code: true | ||
type: page | ||
title: write | ||
--- | ||
|
||
# write | ||
|
||
<SinceBadge version="1.8.0" /> | ||
|
||
Create or replace a document directly into the storage engine. | ||
|
||
This is a low level route intended to bypass Kuzzle actions on document creation, notably: | ||
- check [document validity](/core/1/guide/guides/essentials/data-validation), | ||
- add [kuzzle metadata](/core/1/guide/guides/essentials/document-metadata), | ||
- trigger [realtime notifications](/core/1/guide/guides/essentials/real-time) (unless asked otherwise). | ||
|
||
--- | ||
|
||
## Query Syntax | ||
|
||
### HTTP | ||
|
||
```http | ||
URL: http://kuzzle:7512/<index>/<collection>/_write[?refresh=wait_for][¬ify][&_id=<document ID>] | ||
Method: POST | ||
Body: | ||
``` | ||
|
||
```js | ||
{ | ||
// document content | ||
} | ||
``` | ||
|
||
### Other protocols | ||
|
||
```js | ||
{ | ||
"index": "<index>", | ||
"collection": "<collection>", | ||
"controller": "bulk", | ||
"action": "write", | ||
|
||
"_id": "<documentId>", | ||
"notify": "<boolean>", | ||
"body": { | ||
// document content | ||
} | ||
} | ||
``` | ||
|
||
--- | ||
|
||
## Arguments | ||
|
||
- `collection`: data collection | ||
- `index`: data index | ||
|
||
### Optional: | ||
|
||
- `documentId`: set the document unique ID to the provided value, instead of auto-generating a random ID | ||
- `notify`: if set to true, Kuzzle will trigger realtime notifications | ||
- `refresh`: if set to `wait_for`, Kuzzle will not respond until the newly created document is indexed | ||
|
||
--- | ||
|
||
## Body properties | ||
|
||
Document content to create. | ||
|
||
--- | ||
|
||
## Response | ||
|
||
Returns an object with the following properties: | ||
|
||
- `_id`: created document unique identifier | ||
- `_source`: document content | ||
- `_version`: version of the created document (should be `1`) | ||
- `created`: a boolean telling if a new document has been created | ||
|
||
```javascript | ||
{ | ||
"status": 200, | ||
"error": null, | ||
"index": "<index>", | ||
"collection": "<collection>", | ||
"controller": "bulk", | ||
"action": "write", | ||
"requestId": "<unique request identifier>", | ||
"result": { | ||
"_id": "<documentId>", | ||
"_version": 1, | ||
"created": true, | ||
"_source": { | ||
// ... | ||
}, | ||
} | ||
} | ||
``` |
This file contains 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 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