Writing process

(1) The node to which the request is reached is called the coordinating node. The coordinating node routes the document according to the specific routing algorithm, namely forwarding the request to the specified node (routing algorithm: Hash (doc_id) % Num_Primary_Shard (2) The primary shard of the node processes the request and synchronizes the data to the replica shard Replica Shard (3) The coordination node finds that the primary shard and all the replica shards have been written, and the replica shard is the replica shard. Then return the client result

Read process

(1) request to the node is called the coordination, the coordination of nodes will be conducted according to the document id hash, judgment document in which node, and then according to the random algorithm, from the corresponding nodes randomly selected in the master copy of fragmentation and fragmentation of a query (2) to accept the request returns the result of divided coordinate nodes, coordinating node in the data returned to the client

The query process

The multi-shard search process is divided into two parts: one is to query the matching documents in multiple shards, and the other is to obtain data from multiple shards

1. Query phase

When a request reaches a node, that node is the coordination node for the current request. The coordination node first creates an empty priority queue from + size,

  • Send a query request to the relevant shard
  • Each shard also creates an empty priority queue locally from + size, queries the matching documents, and returns the results to the coordination node, but only containing the document ID and the sort value
  • The coordination node merges the query results returned by other shards

2. Data acquisition stage

  • The coordinating node identifies which documents need to be retrieved and sends multiple GET requests to the relevant shard to retrieve the data
  • Return after shard loading and enriching the document
  • The coordinator node merges the result and returns it to the client