What is NRT in Elasticsearch?

Elasticsearch is a search engine. The platform is known by its NRT or Near Real time feature. The term Near Real Time is also given to the platform because of the short interval between documenting an index and being able to search for it.


What does Cluster mean in Elasticsearch?

Cluster’s concept includes a set of Nodes or servers that all hold your data. A Cluster allows you to look on all nodes, indexing and indexing. Cluster name must be chosen a specific name because in order to be able to place a Node in a Cluster, we need to name that particular Cluster. It is very important to choose on what basis this name should be chosen and what values it contains. The default name of a Cluster is usually Elasticsearch.

What does the term Node mean in Elasticsearch?

A Node actually only contains a server located in Cluster. This Node plays a role in both searching and indexing in a Cluster and keeping our data. Choosing a name for a Node is also important like Cluster. The default name or UUID is set as rand when a Node is built, and you can change it to your liking later. For the admin of the site (Administration), the name Node is very valuable because it must have its name in order to monitor a specific server. The node name is dependent on the cluster name so that if we do not change the default name of a Cluster which is Elasticsearch, node will be displayed as the same name.

Learn about Index in Elasticsearch

An index contains a set of documents that have similar features that we mentioned in the article all about Elasticsearch Part 2. All indexes must be written in lowercase and you can keep as much as you want on a Cluster index. All delete, update, indexing and search operations are executable on one index.

Type in Elasticsearch

A type or type is actually used for the category or partitioning of an Index. For example, you can create a different category for passwords or blog posts by using type documents in an index.


What is Document in Elasticsearch?

A document contains values of information that can be indexed. With Index/Type, you can create and maintain documents in index as many as you want. These documents are JSON (a term used in web programming to send data from the web server towards a web page.) are.

Term Shards & Replicas in Elasticsearch

An Index is capable of storing large amounts of information, but this value is not infinite and comes at a time when the final node side is filled as well. Index dividing feature can be used to solve this problem. Each Index can be divided into smaller sections, each of which is called a Shard. Each of these parts operates independently of each other so that each part of an Index can be stored on the desired part of Node on Cluster 1. Functionality is important for two reasons.

1- Allows you to divide your information horizontally.

2- With this feature, you can perform multiple operations simultaneously on each Shard. This feature is especially efficient when shards are on multiple nodes. Elasticsearch manages how shards are distributed and documented connections to searches performed. In cyberspace, it is possible to lose data at any moment. To prevent this from happening, it is best to back up your data. Elasticsearch allows you to make as many copies as you need from your Shards. These versions are called Replica shard or Replicas.

There are 2 options for preparing these alternative versions. First, node will give you a backup if a Shard crashes. This backup is never stored on the same Node as the original Shard. The second advantage is to increase the search scope between different Shard and the original and backup Shards. A Shard can be with or without a backup. The original Shard is also called the Shard original.


Cluster Health Test in Elasticsearch

Cluster health test is performed in Elasticsearch to confirm how it works properly. An Api such as the following example can be used to check cluster health.

GET localhost:9200/_cat/health?v

In this case, a request is sent and returned from cluster one response. To determine what cluster’s health status is, it’s better than color to determine what the cluster’s health status is. The green status indicates the correct functioning of the cluster. If the status color is yellow, that means all large data and smaller data are available, but some replicas are not yet made. If a part of the data is not available and the cluster is functioning normally until launch, the status color will turn red.

If we want to get all the nodes in a cluster, we can use the following test.

GET localhost:9200/_cat/nodes?v

In this case, a request is sent and a response returns from the cluster.

Build an Index in Cluster

To create cluster index in Elasticsearch using the following command, we create an index called customer.

PUT /customer?pretty

Then, using the command below, we will see a list containing all the available in the command.

GET /_cat/indices?v

In the two examples mentioned above, you can see that in the PUT /customer?pretty command, adding Pretty will cause Json to send the request response from you in a beautiful format. In addition, the response we receive from GET/_cat/indices?v indicates that this index has 5 Primary Shard files, and there is also a Replica available (according to the Pri and Rep columns). Docs.Count also indicates that the existing Index does not have any Document files.
As you can see, the Status color in the table is yellow. The reason for this is not knowing replica Node inside the Index. By moving a copy of Replica to another Node, the Status color will turn green.


Index andQuery a Document

For indexing a customer document, first put the id value equal to 1, then we do so through the following command.

PUT /customer/_doc/1?pretty
“name”: “John Doe”

Click here to read more articles on DevOps.


Then, using api and id, we get the same document that we indexed through the command below.

GET /customer/_doc/1?pretty

The answer to this request is as follows:

Clear an Index in Cluster

To clear an index, we use the following api.

DELETE /customer?pretty


In this example, we cleared an index with the name of the customer, and as you can see, after deleting the customer, we received the list of available indexes and there was no index with the name of the customer.


To view part two:

Part 2

And in the end,

Mirbazorgi’s website aims to help you learn and fix your problems by providing articles and practical experiences. Email me if you have any questions.