Document in Elasticsearch

Data in Elasticsearch is stored in the form of documents. These documents are addressable and have identifiable attributes that can be queried from the store. A sample document (JSON format) is shown in the figure:


Figure 05: Sample document in Elasticsearch

Similar to String objects in Java, documents in Elasticsearch are immutable, so once created, you cannot update them. If you would want to update one, you have to either reindex or replace it.

Apart from the real data, a document does have additional information about the document itself, called document metadata. The most important metadata for a document are as follows:

  • _index: Logical grouping where documents having a common reason to exist in Elasticsearch are grouped together. For example, all the customer index in an organization could be saved in customer index and so on. The _index value cannot start with an underscore nor can it contain commas and should be in lowercase.
  • _type: Class of object which the document belongs to or represents. This allows Elasticsearch to logically partition data inside an index. These are usually subcategories existing inside an index in Elasticsearch. The _type cannot start with an underscore or a period but can be either lowercase or uppercase; similar to _index, they cannot contain commas and are limited to 256 character length.
  • _id: Uniquely identifies a document when this string (_id) is combined with _index and _type. It can either be explicitly provided or Elasticsearch would automatically put a value for this.
In object-oriented and functional programming, an immutable object (unchangeable object) is an object whose state cannot be modified after it is created.
- Wikipedia

Figure 06: Multiple documents (string format) in Elasticsearch
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.48.161