code | type | title | description |
---|---|---|---|
true |
page |
importData |
Creates, updates or deletes large amounts of documents as fast as possible. |
Creates, updates or deletes large amounts of documents as fast as possible.
This route is faster than the document:m*
routes family (e.g. document:mCreate), but no real-time notifications will be generated, even if some of the documents in the import match subscription filters.
:::: tabs ::: tab Java
public CompletableFuture<Map<String, Object>> importData(
String index,
String collection,
ArrayList<Map<String, Object>> bulkData
) throws NotConnectedException, InternalException
Argument | Type | Description |
---|---|---|
index |
String |
Index name |
collection |
String |
Collection name |
bulkData |
ArrayList<Map<String, Object>> |
Bulk operations to perform, following ElasticSearch Bulk API |
This API takes a JSON array containing a list of objects working in pairs.
In each pair, the first object specifies the action to perform (the most common is create
) and the second specifies the document itself, like in the example below:
[
// Action object
{ "create": { "_id": "id" } },
// Document object
{ "myField": "myValue", "myOtherField": "myOtherValue" },
// Another action object
{ "create": { "_id": "another-id" } },
// Another document object
{ "myField": "anotherValue", "myOtherField": "yetAnotherValue" }
];
Possible actions are create
, index
, update
, delete
.
Learn more at Elasticsearch Bulk API
A Map<String, Any?> containing 2 arrays:
Property | Type | Description |
---|---|---|
successes |
ArrayList<Map<String, Object>> |
Array of object containing successful document import |
errors |
ArrayList<Map<String, Object>> |
Array of object containing failed document import |
Each item of the successes
array is an object containing the action name as key and the corresponding object contain the following properties:
Property | Type | Description |
---|---|---|
_id |
String |
Document unique identifier |
status |
Integer |
HTTP status code for that query |
Each item of the errors
array is an object containing the action name as key and the corresponding object contain the following properties:
Property | Type | Description |
---|---|---|
_id |
String |
Document unique identifier |
status |
Integer |
HTTP status code for that query |
error |
<Map<String, Object> |
Error object |
Each error
object contain the following properties:
Property | Type | Description |
---|---|---|
type |
String |
Elasticsearch client error type |
reason |
String |
human readable error message |
<<< ./snippets/import-data-java.java
::: ::: tab Kotlin
fun importData(
index: String,
collection: String,
bulkData: ArrayList<Map<String, Any?>>
): CompletableFuture<Map<String, Any?>>
Argument | Type | Description |
---|---|---|
index |
String |
Index name |
collection |
String |
Collection name |
bulkData |
ArrayList<Map<String, Any?>> |
Bulk operations to perform, following ElasticSearch Bulk API |
This API takes a JSON array containing a list of objects working in pairs.
In each pair, the first object specifies the action to perform (the most common is create
) and the second specifies the document itself, like in the example below:
[
// Action object
{ "create": { "_id": "id" } },
// Document object
{ "myField": "myValue", "myOtherField": "myOtherValue" },
// Another action object
{ "create": { "_id": "another-id" } },
// Another document object
{ "myField": "anotherValue", "myOtherField": "yetAnotherValue" }
];
Possible actions are create
, index
, update
, delete
.
Learn more at Elasticsearch Bulk API
A Map<String, Any?> containing 2 arrays:
Property | Type | Description |
---|---|---|
successes |
ArrayList<Map<String, Any?>> |
Array of object containing successful document import |
errors |
ArrayList<Map<String, Any?>> |
Array of object containing failed document import |
Each item of the successes
array is an object containing the action name as key and the corresponding object contain the following properties:
Property | Type | Description |
---|---|---|
_id |
String |
Document unique identifier |
status |
Int |
HTTP status code for that query |
Each item of the errors
array is an object containing the action name as key and the corresponding object contain the following properties:
Property | Type | Description |
---|---|---|
_id |
String |
Document unique identifier |
status |
Int |
HTTP status code for that query |
error |
<Map<String, Any?> |
Error object |
Each error
object contain the following properties:
Property | Type | Description |
---|---|---|
type |
String |
Elasticsearch client error type |
reason |
String |
human readable error message |
<<< ./snippets/import-data-kotlin.kt
::: ::::