Learn R Programming

elastic (version 0.3.0)

docs_get: Get documents via the get API.

Description

Get documents via the get API.

Usage

docs_get(index = NULL, type = NULL, id = NULL, source = FALSE,
  fields = NULL, exists = FALSE, raw = FALSE, callopts = list(),
  verbose = TRUE, ...)

Arguments

index
Index
type
Document type
id
Document id.
source
(logical) If TRUE, return source.
fields
Fields to return from the response object.
exists
(logical) Only return a logical as to whether the document exists or not.
raw
If TRUE (default), data is parsed to list. If FALSE, then raw JSON.
callopts
Curl args passed on to httr::POST.
verbose
If TRUE (default) the url call used printed to console.
...
Further args passed on to elastic search HTTP API as parameters.

References

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

Examples

Run this code
docs_get(index='shakespeare', type='line', id=10)
docs_get(index='shakespeare', type='line', id=3)
docs_get(index='shakespeare', type='line', id=3, source=TRUE)

# Get certain fields
docs_get(index='shakespeare', type='line', id=10, fields='play_name')
docs_get(index='shakespeare', type='line', id=10, fields=c('play_name','speaker'))

# Just test for existence of the document
docs_get(index='plos', type='article', id=1, exists=TRUE)
docs_get(index='plos', type='article', id=123456, exists=TRUE)

Run the code above in your browser using DataLab