NYC's Blog - 详解ElasticSearch中的路由(_routing)机制 的评论 http://niyanchun.com/routing-in-es.html zh-CN 注:本文的所有测试基于ES 7.1.0版本。ES中的路由(routing)机制决定一个document存储到索引的哪个shard上面去,即文档到shard的路由。计算公式为:shard_num ... Sun, 04 Jul 2021 16:16:30 +0800 Sun, 04 Jul 2021 16:16:30 +0800 NYC http://niyanchun.com/routing-in-es.html/comment-page-1#comment-688 http://niyanchun.com/routing-in-es.html/comment-page-1#comment-688 Sun, 04 Jul 2021 16:16:30 +0800 NYC 可能会,但自定义路由的时候负载均衡需要用户自己去保证,一般要选比较合适的key

]]>
http://niyanchun.com/routing-in-es.html/comment-page-1#comment-688#comments
luke http://niyanchun.com/routing-in-es.html/comment-page-1#comment-687 http://niyanchun.com/routing-in-es.html/comment-page-1#comment-687 Wed, 16 Jun 2021 11:35:10 +0800 luke 但这样不是会造成数据倾斜,导致负载不均衡吗

]]>
http://niyanchun.com/routing-in-es.html/comment-page-1#comment-687#comments
NYC http://niyanchun.com/routing-in-es.html/comment-page-1#comment-678 http://niyanchun.com/routing-in-es.html/comment-page-1#comment-678 Sat, 08 May 2021 09:02:34 +0800 NYC 这里说的提高效率指的是search,而不是通过doc_id(即_id)去访问,search的时候是不知道_id的,如果知道也就不用search了。

]]>
http://niyanchun.com/routing-in-es.html/comment-page-1#comment-678#comments
jie http://niyanchun.com/routing-in-es.html/comment-page-1#comment-677 http://niyanchun.com/routing-in-es.html/comment-page-1#comment-677 Fri, 07 May 2021 18:50:52 +0800 jie 作者大大,您好。看了文章,我有一个问题。就是文中您说:“当然,很多时候自定义路由是为了减少查询时扫描shard的个数,从而提高查询效率。” 那么,为啥不是自定义路由的时候,就是默认情况下查询效率会低呢?默认情况下,elasticsearch使用_id作为routing的,那也可以通过将这个_id的值做hash运算,再取余,得到一个分片,然后直接精确的去这个分片来进行查询不就行了吗

]]>
http://niyanchun.com/routing-in-es.html/comment-page-1#comment-677#comments
NYC http://niyanchun.com/routing-in-es.html/comment-page-1#comment-675 http://niyanchun.com/routing-in-es.html/comment-page-1#comment-675 Fri, 02 Apr 2021 17:13:04 +0800 NYC 学习了~

]]>
http://niyanchun.com/routing-in-es.html/comment-page-1#comment-675#comments
徐小鹏 http://niyanchun.com/routing-in-es.html/comment-page-1#comment-674 http://niyanchun.com/routing-in-es.html/comment-page-1#comment-674 Wed, 31 Mar 2021 17:23:56 +0800 徐小鹏 其实对于TOB领域,一般Routing会用于一个租户(即公司ID)的概念,用了Routing起到了租户隔离的作用

]]>
http://niyanchun.com/routing-in-es.html/comment-page-1#comment-674#comments
NYC http://niyanchun.com/routing-in-es.html/comment-page-1#comment-637 http://niyanchun.com/routing-in-es.html/comment-page-1#comment-637 Thu, 15 Oct 2020 16:03:10 +0800 NYC bulk接口中每条document都可以添加routing参数,和单条的效果一样,同时也保证了bulk的效率

]]>
http://niyanchun.com/routing-in-es.html/comment-page-1#comment-637#comments
Gordon http://niyanchun.com/routing-in-es.html/comment-page-1#comment-636 http://niyanchun.com/routing-in-es.html/comment-page-1#comment-636 Thu, 15 Oct 2020 15:50:58 +0800 Gordon 那写入ES 只能单条写入加routing了? 不能bulk批量加吧? 会影响写入效率么?

]]>
http://niyanchun.com/routing-in-es.html/comment-page-1#comment-636#comments
NYC http://niyanchun.com/routing-in-es.html/comment-page-1#comment-635 http://niyanchun.com/routing-in-es.html/comment-page-1#comment-635 Tue, 13 Oct 2020 17:07:49 +0800 NYC 其实文章里面已经提到了:

  1. 如果自定义了routing,那么文档的增删改查操作就必须指定routing,否则,会报错(因为文档的操作都是通过docid进行的,自定义routing以后,docid不再全局唯一了,如果不指定routing,仅靠docid是不足以定位到具体的doc的,或者说如果有多条,ES是不知道用户意图操作哪个doc的)。
  2. 如果是查询操作,则自定义不产生任何影响。但是查的时候可以选择性的指定routing,这样可以提高查询的性能,因为可以根据routing计算只查询哪些shard了。

上面的第1个我觉得也不算什么弊端,毕竟如果自定义了routing,那肯定在后面的操作中就是要使用的。

]]>
http://niyanchun.com/routing-in-es.html/comment-page-1#comment-635#comments
Gordon http://niyanchun.com/routing-in-es.html/comment-page-1#comment-634 http://niyanchun.com/routing-in-es.html/comment-page-1#comment-634 Tue, 13 Oct 2020 16:31:21 +0800 Gordon 有弊端的吧? 例如以用户ID作为routing 只适合按用户的搜索 没有传用户ID的就无法指定routing查询了

]]>
http://niyanchun.com/routing-in-es.html/comment-page-1#comment-634#comments