Description Usage Arguments References Examples
Get documents
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
conn |
an Elasticsearch connection object, see |
index |
(character) The name of the index. Required |
id |
(numeric/character) The document ID. Can be numeric or character. Required |
type |
(character) The type of the document. optional |
source |
(logical) If |
fields |
Fields to return from the response object. |
source_includes, source_excludes |
(character) fields to include in the returned document, or to exclude. a character vector |
exists |
(logical) Only return a logical as to whether the document exists or not. |
raw |
If |
callopts |
Curl args passed on to crul::HttpClient |
verbose |
If TRUE (default) the url call used printed to console. |
... |
Further args passed on to elastic search HTTP API as parameters. |
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-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 | ## Not run:
(x <- connect())
if (!index_exists(x, "shakespeare")) {
shakespeare <- system.file("examples", "shakespeare_data_.json",
package = "elastic")
shakespeare <- type_remover(shakespeare)
invisible(docs_bulk(x, shakespeare))
}
docs_get(x, index='shakespeare', id=10)
docs_get(x, index='shakespeare', id=12)
docs_get(x, index='shakespeare', id=12, source=TRUE)
# Get certain fields
if (gsub("\\.", "", x$ping()$version$number) < 500) {
### ES < v5
docs_get(x, index='shakespeare', id=10, fields='play_name')
docs_get(x, index='shakespeare', id=10, fields=c('play_name','speaker'))
} else {
### ES > v5
docs_get(x, index='shakespeare', id=10, source='play_name')
docs_get(x, index='shakespeare', id=10, source=c('play_name','speaker'))
}
# Just test for existence of the document
docs_get(x, index='plos', id=1, exists=TRUE)
docs_get(x, index='plos', id=123456, exists=TRUE)
# source includes / excludes
docs_get(x, index='shakespeare', id=10, source_includes = "play_name")
docs_get(x, index='shakespeare', id=10, source_excludes = "play_name")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.