Skip to content

elasticsearch get-document

get document from index

Description

Retrieves the specified JSON document from an index

Synopsis

elasticsearch get-document
    [--site <site>]
    [--cluster <cluster>]
    [--filter_path <filter_path>]
    --index <index>
    <id>

Arguments

site - (string)

     Site where this command will be executed
     Example: --site "site-1"
     Default: input.site      Attributes: optional

cluster - (string)

     Name of elastic search cluster
     Example: --cluster "elastic-default"
     Default: elastic-default      Attributes: optional

filter_path - (string)

     Path in the response. Filters and returns only parts of response matching this path
     Example: --filter_path "index.mappings.properties.*"
     Default: _None_      Attributes: optional, multiple allowed

index - (string)

     Name of the index that contains the document.
     Example: --index "students"
     Default: _None_      Attributes: required

id - (int)

     Unique identifier of the document.
     Example: 1
     Default: _None_      Attributes: required

Examples

Input:

! elasticsearch get-document --cluster "elastic-1" --index "my-index-000001" 1
Output:
{
  "_index": "my-index-000001",
  "_type": "_doc",
  "_id": "1",
  "_version": 1,
  "_seq_no": 0,
  "_primary_term": 1,
  "found": true,
  "_source": {
    "@timestamp": "2099-11-15T13:12:00",
    "message": "GET /search HTTP/1.1 200 1070000",
    "user": {
      "id": "kimchy"
    }
  }
}

Access Control

To use this command, you need access to the following:

Field Value
Action "read"
Service Type "elasticsearch"
Service Instance cluster
Namespace
Object Type "index"
Object ID index

Please see Access Control for details.