Learn R Programming

elastic (version 0.3.0)

docs_create: Create a document in an index.

Description

Create a document in an index.

Usage

docs_create(index, type, id, body, version = NULL, version_type = NULL,
  op_type = NULL, routing = NULL, parent = NULL, timestamp = NULL,
  ttl = NULL, refresh = NULL, timeout = NULL, callopts = list(), ...)

Arguments

index
(character) The name of the index. Required
type
(character) The type of the document. Required
id
(numeric) The document ID. Required
body
The document.
version
(character) Explicit version number for concurrency control
version_type
(character) Specific version type. One of internal, external, external_gte, or force
op_type
(charcter) Operation type. One of create, or ...
routing
(charcter) Specific routing value
parent
(numeric) A parent document ID
timestamp
(date) Explicit timestamp for the document
ttl
(aka time to live) Expiration time for the document. Expired documents will be expunged automatically. The expiration date that will be set for a document with a provided ttl is relative to the timestamp of the document, meaning it can be
refresh
(logical) Refresh the index after performing the operation
timeout
(charcter) Explicit operation timeout, e.g,. 5m (for 5 minutes)
callopts
Curl args passed on to DELETE
...
Further args to query DSL

References

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-index_.html

Examples

Run this code
docs_create(index='plos', type='article', id=1002, body=list(id="12345", title="New title"))
docs_get(index='plos', type='article', id=1002) # and the document is there now

Run the code above in your browser using DataLab