Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to control the concurrency of document operations in Elasticsearch

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

In this issue, the editor will bring you about how to control the concurrency of document operations in Elasticsearch. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

Subject to Elasticsearch 7.9.2.

Concurrency control

Pessimistic concurrency control: when operating resources that may change conflicts, the resources are locked and unlocked after the operation is completed.

Optimistic concurrency control: think that the possibility of change conflict is very small, first do not lock, directly operate, if the data is found to be modified in the process of reading and writing, then the update fails. It is up to the caller to decide how to resolve the change conflict.

ES adopts optimistic concurrency control.

Concurrency Control of ES

The ES document is immutable. To modify the document is to delete the original document and then create a new document with the same id as the original document, while the _ version field is 1 more than the original document.

The document of ES has _ seq_no and _ primany_term fields. When updating the document through REST API, add if_seq_no and if_primany_term parameters to QueryString for concurrency control. The implication of these two parameters is that the update will succeed only if the _ seq_no and _ primany_term of the document are equal to the passed if_seq_no and if_primany_term, respectively.

The above is the editor for you to share how to carry out the concurrency control of document operations in Elasticsearch, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report