Learn R Programming

elasticsearchr (version 0.3.1)

create_metadata: Create Bulk API metadata.

Description

The fastest way to index, delete or update many documents, is via the Bulk API. This requires that each document have the action combined with the document's metadata (index, type and id) sent to the API. This information is encapulated as a JSON object, that this function is responsible for generating.

Usage

create_metadata(action, index, doc_type, id = NULL, n = NULL)

Arguments

action

One of: "index", "create", "update" or "delete".

index

The name of the index where the documents reside (or will reside).

doc_type

The name of the document type where the documents reside (or will reside).

id

[optional] Character vector of document ids.

n

[optional] Integer number of repeated metadata description objects that need to be returned (if id is not specified).

Value

A character vector of Bulk API document information objects.

See Also

https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html for more information on the information required by the Elasticsearch Bulk API.

Examples

Run this code
# NOT RUN {
create_metadata("index", "iris", "data", n = 2)
'{\"index\": {\"_index\": \"iris\", \"_type\": \"data\"}}'
'{\"index\": {\"_index\": \"iris\", \"_type\": \"data\"}}'
# }

Run the code above in your browser using DataLab