Skip to content

Latest commit

 

History

History
169 lines (123 loc) · 7.05 KB

index.md

File metadata and controls

169 lines (123 loc) · 7.05 KB
code type title description
true
page
importData
Creates, updates or deletes large amounts of documents as fast as possible.

importData

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

Arguments

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

bulkData

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

Return

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

Usage

<<< ./snippets/import-data-java.java

::: ::: tab Kotlin

Arguments

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

bulkData

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

Return

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

Usage

<<< ./snippets/import-data-kotlin.kt

::: ::::