Description Usage Arguments Details References Examples
Get multiple documents via the multiple get API
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
conn |
an Elasticsearch connection object, see |
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 |
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 |
verbose |
If TRUE (default) the url call used printed to console. |
... |
Further args passed on to elastic search HTTP API as parameters. |
You can pass in one of three combinations of parameters:
Pass in something for index
, type
, and id
.
This is the simplest, allowing retrieval from the same index, same type,
and many ids.
Pass in only index
and type_id
- this allows you to
get multiple documents from the same index, but from different types.
Pass in only index_type_id
- this is so that you can get
multiple documents from different indexes and different types.
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.html
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 42 | ## Not run:
(x <- connect())
if (!index_exists(x, 'plos')) {
plosdat <- system.file("examples", "plos_data.json",
package = "elastic")
plosdat <- type_remover(plosdat)
invisible(docs_bulk(x, plosdat))
}
# same index, many ids
docs_mget(x, index="plos", ids=c(9,10))
# Same index and type
docs_mget(x, index="plos", type="_doc", ids=c(9,10))
tmp <- docs_mget(x, index="plos", ids=c(9, 10), raw=TRUE)
es_parse(tmp)
docs_mget(x, index="plos", ids=c(9, 10), source='title')
docs_mget(x, index="plos", ids=c(14, 19), source=TRUE)
# curl options
docs_mget(x, index="plos", ids=1:2, callopts=list(verbose=TRUE))
# Same index, but different types
if (index_exists(x, 'shakespeare')) index_delete(x, 'shakespeare')
shakedat <- system.file("examples", "shakespeare_data.json",
package = "elastic")
invisible(docs_bulk(x, shakedat))
docs_mget(x, index="shakespeare", type_id=list(c("scene",1), c("line",20)))
docs_mget(x, index="shakespeare", type_id=list(c("scene",1), c("line",20)),
source='play_name')
# Different indices and different types pass in separately
docs_mget(x, index_type_id = list(
c("shakespeare", "line", 20),
c("plos", "article", 1)
)
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.