举个例子,一个index有3个primary shard,P0,P1,P2
每次增删改查一个document的时候,都会带过来一个routing number,默认就是这个document的_id(可能是手动指定,也可能是自动生成)
routing = _id,假设_id=1
会将这个routing值,传入一个hash函数中,产出一个routing值的hash值,hash(routing) = 21
然后将hash函数产出的值对这个index的primary shard的数量求余数,21 % 3 = 0
就决定了,这个document就放在P0上。
决定一个document在哪个shard上,最重要的一个值就是routing值,默认是_id,也可以手动指定,相同的routing值,每次过来,从hash函数中,产出的hash值一定是相同的
无论hash值是几,无论是什么数字,对number_of_primary_shards求余数,结果一定是在0~number_of_primary_shards-1之间这个范围内的。0,1,2。
(3)_id or custom routing value
默认的routing就是_id
也可以在发送请求的时候,手动指定一个routing value,比如说put /index/type/id?routing=user_id
手动指定routing value是很有用的,可以保证说,某一类document一定被路由到一个shard上去,那么在后续进行应用级别的负载均衡,以及提升批量读取的性能的时候,是很有帮助的
详细解决方案
document数据路由原理
热度:20 发布时间:2024-01-24 15:28:47.0
相关解决方案
- jquery中$(document).ready(function()是jquery开始要写的一句话,javaWeb项目中,这句话什么时候开始实施呢
- document.form1.submit() 揭示拒绝访问
- document.all的用法,该如何处理
- document.getElementById(。)对象不存在,该如何解决
- document.getElementById("input").checked;转换成Jquery,如何写
- 无刷新更换验证码图片"onclick="document.getElementById('ImgCode').src='./VerifyCode.aspx'"无效,该怎么处理
- 怎么自动执行<a href="document.html" target="parent">my document</a> 呢
- document.write()不覆盖其它元素,该怎么解决
- Microsoft JScript 运行时异常: 'document.getElementById(.)' 为空或不是对象
- 问在线编辑WORD(SharePoint.Document),非正常退出WORD时(比如结束进程),第二次打开就显示已被用户锁定.请教如何解决
- 郁闷、难过啊一个关于JS跨页面访问的有关问题,'Parent.top_frame.document.all.T1 '为空或不是对象
- 服务控件 当按下回车时触发的有关问题 提示:"Microsoft JScript 运行时异常: 'document.all[.]' 为空或不是对象"
- document.GetElementById('PIDIn').select()对象不支持此属性或方法?该如何处理
- document.write(str);的有关问题
- document.getElementById()里面能放参数吗?解决办法
- document.createElement("div")后怎么取他的属性
- 怎么得到光标标在 Word.Document 中位置
- java.lang.IllegalArgumentException: Document base C:\Program Files\Ap解决方法
- C# 中的 webbrowser.Document.Body.appendChild 没真正写入到源网页中
- The associated COM server does not support ActiveX Document embedding. ...
- document.write设置格式,该如何处理
- :document.execCommand('saveas','false','C:\\download.txt');保存文件的文件有关问题,
- document.execCommand("SaveAs")为何只能选择bmp格式的,该如何解决
- document.body.clientLeft 是什么意思,该如何解决
- 一个小疑点, document.getElementById("Textbox1") 后面没有value这些提示了
- 求 window.parent.document.getElementById(.)为空或不是对象的解决方法
- document.getElementById("test").innerHTML= 这里内容如何写
- document.all.name<%=i%>value能不能动态?求大神解答.解决方案
- javascript:document.sele.submit()异常,
- window.opener.document.form1.text0.value中如果使用变量?解决办法