Get documents
Get documents
docs_get( conn, index, id, type = NULL, source = NULL, fields = NULL, source_includes = NULL, source_excludes = NULL, exists = FALSE, raw = FALSE, callopts = list(), verbose = TRUE, ... )
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. |
## 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)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.