网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

Elasticsearch写一致性在5.x版本之后已经被废弃掉-创新互联

1 问题缘由

最近继续在探索es的更多内容,查阅了相关资料(包括博客文章跟其它一些教程),学习到写一致性原理的相关知识,其本身并不难理解,但是一定要在实践中经过验证才会有更深的体会,就像在项目过使用过es做各种聚合统计搜索分析,跟没使用过,差别还是很大的。
于是在es 5.4的版本上进行测试:

创新互联建站专注于企业营销型网站建设、网站重做改版、开阳网站定制设计、自适应品牌网站建设、HTML5商城网站建设、集团公司官网建设、外贸营销网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为开阳等各大城市提供网站开发制作服务。
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
}

可以看到并不能识别consistency,然后我继续使用5.2、5.6和老版本1.7进行测试,发现5.x的版本都是不行的,但是1.7的可以。所以想到很有可能写一致性在es 5.x版本之后应该是已经废弃掉的。
于是上网查找一下资料,搜索出来的结果,文档竟然几乎都是来自同一份源文档,基于es 5.2的版本,但是却还是把这个写一致性带上。
所以没有办法,只能查阅官方文档。

2 写一致性在es 5.x版本已经废弃掉

官方文档对于es 5.x的变化说明如下:
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.

可以查看: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?

后续在es 6.x是否还会有其它变化?
当然目前我不会去查阅es 6.x的相关资料,因为公司也只是刚从es 1.x 2.x升级到5.6,并且很大一部分项目还是使用旧的,所以目标很明确,后面更多是会关注es 5.x版本的,因为时间精力都是十分有限的。
就像现在spark已经是2.x了,但是由于公司使用的最新版本是1.6.3,所以对于spark,我个人的精力,包括spark的开发习惯,也都还是基于spark 1.6的。
当然,后续也肯定会把精力放到新的版本上。

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


文章名称:Elasticsearch写一致性在5.x版本之后已经被废弃掉-创新互联
当前地址:http://bjjierui.cn/article/ccdijh.html

其他资讯