Elasticsearch Document



Elasticsearch Document

Opster Team

July 2020, Version: 1.7-8.0


Before you begin reading the explanation below, try running the free ES Health Check-Up get actionable recommendations that can improve Elasticsearch performance and prevent serious incidents. Just 2 minutes to complete and you can check your threadpools, memory, snapshots and many more

Document in Elasticsearch

Overview

A document is simply a json document that is stored in Elasticsearch index. It consists of one or more fields; where each field has its own data type. This field type defines the type of data that can be stored in the field such as integer, string, object. Document is schema-free, which means we do not require to specify schema before indexing document, when a field is indexed for the first time, its type is decided and set.

Examples:

Creating A document : to create a document in the users index.

POST  /users/_doc 
{
    "name" : "Petey",
    "lastname" : "Cruiser",
    "email" : "petey@gmail.com"
}

In the above request, we haven’t mentioned id for the document so index operation generates a unique ID for the document. Here _doc is the type of document. We can provide this type to user-defined type also where user index may store user type document.

POST  /users/_doc/1
{
    "name" : "Petey",
    "lastname" : "Cruiser",
    "email" : "petey@gmail.com"
}

In the above query, the document will be created with id 1.

You can use the below ‘GET’ query to get a document from the index using id

GET  /users/_doc/1

Bellow is the result containing the document (in _source field) with metadata:-

{
    "_index": "users",
    "_type": "_doc",
    "_id": "1",
    "_version": 1,    "_seq_no": 1,    "_primary_term": 1,
    "found": true,
    "_source": {
        "name": "Petey",
        "lastname": "Cruiser",
        "email": "petey@gmail.com"
    }
}
Notes

Starting version 7.0 types are deprecated, so for backward compatibility on version 7.x all docs are under type ‘_doc’, starting 8.x type will be completely removed from ES APIs


Related log errors to this ES concept


Failed to render document ; skipping it
Unexpected error while indexing monitoring document
Could not find token document for refresh
Could not find token document with refreshtoken
Role uses document and/or field level security; which is not enabled by the current license
Failed to process
meta document not found
No river _meta document found after attempts
Built a DLS BitSet that uses bytes. the DLS BitSet cache has a maximum size of bytes.
Could not find token document for refresh token
Could not get token document for refresh after all retries
Could not get token document for refresh. retrying

< Page: 1 of 2 >


About Opster

Opster detects, prevents, optimizes and automates everything needed to run mission-critical Elasticsearch

Find Configuration Errors

Analyze Now