docs_mget: Get multiple documents via the multiple get API.

Description Usage Arguments Details References Examples

View source: R/docs_mget.r

Description

Get multiple documents via the multiple get API.

Usage

1
2
3
docs_mget(index = NULL, type = NULL, ids = NULL, type_id = NULL,
  index_type_id = NULL, source = NULL, fields = NULL, raw = FALSE,
  callopts = list(), verbose = TRUE, ...)

Arguments

index

Index. Required.

type

Document type. Required.

ids

More than one document id, see examples.

type_id

List of vectors of length 2, each with an element for type and id.

index_type_id

List of vectors of length 3, each with an element for index, type, and id.

source

(logical) If TRUE, return source.

fields

Fields to return from the response object.

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.

Details

You can pass in one of three combinations of parameters:

References

https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
## Not run: 
connect()

if (!index_exists('plos')) {
  plosdat <- system.file("examples", "plos_data.json", package = "elastic")
  invisible(docs_bulk(plosdat))
}

# Same index and type
docs_mget(index="plos", type="article", ids=c(9,10))

tmp <- docs_mget(index="plos", type="article", ids=c(9, 10), 
  raw=TRUE)
es_parse(tmp)
docs_mget(index="plos", type="article", ids=c(9, 10), 
  source='title')
docs_mget(index="plos", type="article", ids=c(14, 19), 
  source=TRUE)

# curl options
library("httr")
docs_mget(index="plos", type="article", ids=1:2, callopts=verbose())

# Same index, but different types
if (!index_exists('shakespeare')) {
  shakedat <- system.file("examples", "shakespeare_data.json", package = "elastic")
  invisible(docs_bulk(shakedat))
}

docs_mget(index="shakespeare", type_id=list(c("scene",1), c("line",20)))
docs_mget(index="shakespeare", type_id=list(c("scene",1), c("line",20)), 
  source='play_name')

# Different indices and different types pass in separately
docs_mget(index_type_id = list(
  c("shakespeare", "line", 20), 
  c("plos", "article", 1)
 )
)

## End(Not run)

ropensci/elastic documentation built on Dec. 17, 2018, 11:08 a.m.