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

Elasticsearch write consistency has been abandoned since version 5.x

2025-02-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

1 the cause of the problem

Recently continue to explore more content of es, access to relevant materials (including blog articles and other tutorials), learned to write the principle of consistency of the relevant knowledge, it is not difficult to understand, but must be verified in practice to have a deeper experience, just like in the project has used es to do a variety of aggregate statistical search and analysis, with no use, the difference is still big.

So it was tested on the version of es 5.4:

PUT myblog/article/1?consistency=all {"title": "test"} {"error": {"root_cause": [{"type": "illegal_argument_exception", "reason": "request [/ myblog/article/1] contains unrecognized parameter: [consistency]"}], "type": "illegal_argument_exception" "reason": "request [/ myblog/article/1] contains unrecognized parameter: [consistency]"}, "status": 400}

You can see that consistency is not recognized, and then I continue to test it with 5.2,5.6 and the old version 1.7, and find that the 5.x version doesn't work, but 1.7 works. So it's possible that write consistency should have been abandoned after the es 5.x release.

So look up the information on the Internet, and the search results show that almost all the documents come from the same source document, based on the version of es 5.2, but still bring this write consistency with you.

So we have no choice but to consult the official documents.

2 write consistency has been abandoned in es 5.x version

The official documentation describes the changes to es 5.x as follows:

WriteConsistencyLevel removed on write requestsedit

In previous versions of Elasticsearch, the various write requests had a setWriteConsistencyLevel method to set the shard consistency level for write operations. However, the semantics of write consistency were ambiguous as this is just a pre-operation check to ensure the specified number of shards were available before the operation commenced. The write consistency level did not guarantee that the data would be replicated to those number of copies by the time the operation finished. The setWriteConsistencyLevel method on these write requests has been changed to setWaitForActiveShards, which can take a numerical value up to the total number of shard copies or ActiveShardCount.ALL for all shard copies. The default is to just wait for the primary shard to be active before proceeding with the operation. See the section on wait for active shards for more details.

This change affects IndexRequest, IndexRequestBuilder, BulkRequest, BulkRequestBuilder, UpdateRequest, UpdateRequestBuilder, DeleteRequest, and DeleteRequestBuilder.

You can view: https://www.elastic.co/guide/en/elasticsearch/reference/5.6/breaking_50_java_api_changes.html#_writeconsistencylevel_removed_on_write_requests

3 es 6.x?

Will there be any other changes in es 6.x?

Of course, at present, I will not look up the relevant materials of es 6.x, because the company has only just upgraded from es 1.x 2.x to 5.6, and a large part of the projects are still using old ones, so the goal is very clear. Later, I will pay more attention to es 5.x version, because time and energy are very limited.

Just like now spark is 2.x, but since the latest version used by the company is 1.6.3, my personal energy for spark, including spark development habits, is still based on spark 1.6.

Of course, we will certainly focus on the new version in the future.

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