Elasticsearch: How is the data read?

In this article, let's learn more about how Elasticsearch handles data reading. By the end of this article, you'll have a solid understanding of routing, Adaptive Replica Selection (ARS) and the overall data reading workflow in Elasticsearch. For more information on the operation of Elasticsearch, please read " Elasticsearch: Thoroughly understand Elasticsearch data operations ".

Routing is integral to this process, but there are other factors to consider. Keep in mind that our talk will mostly revolve around reading a single document, when we'll dive into search queries.

First, when a read request is made, it is routed to a specific node. This node is called the coordinator node and is responsible for coordinating requests.

Now, you might be wondering what this coordination entails. The first step, then, involves determining the location of the document we want to retrieve. Routing is used for this purpose.

You may have pointed out earlier in our talk that routing helps determine which shard holds a particular document. That's still true, but let's be more precise. If the shard has been replicated, the route will resolve to the primary shard or the replication group (the primary shard and its replica shards are collectively referred to as a replication group, please read the article "Elasticsearch: Replication - replication" for details ) . This duplication almost always happens for a variety of reasons.

To ensure scalability, Elasticsearch fetches documents in a certain way. If you only retrieve documents from the primary shard each time, all retrievals will end up on the same shard. However, this strategy does not scale effectively as the workload grows. Elasticsearch uses a mechanism called Adaptive Replica Selection (ARS) to solve this problem.

ARS is critical to the retrieval process. It chooses the best shard replica based on various criteria. While I won't go into the details of the evaluation formula right now, rest assured that Elasticsearch takes a comprehensive approach to determining the best shard replicas.

 

Guess you like

Origin blog.csdn.net/UbuntuTouch/article/details/131040911