docs_get: Get documents

Description Usage Arguments References Examples

View source: R/docs_get.r

Description

Get documents

Usage

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

Arguments

index

(character) The name of the index. Required

type

(character) The type of the document. Required

id

(numeric/character) The document ID. Can be numeric or character. Required

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

https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Not run: 
docs_get(index='shakespeare', type='line', id=10)
docs_get(index='shakespeare', type='line', id=12)
docs_get(index='shakespeare', type='line', id=12, source=TRUE)

# Get certain fields
if (gsub("\\.", "", ping()$version$number) < 500) {
  ### ES < v5
  docs_get(index='shakespeare', type='line', id=10, fields='play_name')
  docs_get(index='shakespeare', type='line', id=10, 
    fields=c('play_name','speaker'))
} else {
  ### ES > v5
  docs_get(index='shakespeare', type='line', id=10, source='play_name')
  docs_get(index='shakespeare', type='line', id=10, 
    source=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)

## End(Not run)

ropensci/elastic documentation built on April 14, 2018, 10:22 a.m.