Basically a hash is performed (details I'm not entirely sure about) and the doc is sent to shard (hashed id)%(num shards). Really, though, I'm not sure there's a good reason to dig into the details other than curiosity.....
If you change the number of shards, you'll get into trouble. All that said, you can assign docs to shards using "custom routing", sometimes called "custom sharding" if you really need to control which shard a doc goes to. Best Erick On Thu, Feb 21, 2013 at 12:46 AM, Rollin.R.Ma (lab.sh04.Newegg) 41099 < rollin.r...@newegg.com> wrote: > Now it is ok truly, but I met the trouble yesterday, I guess the > environment problem. > Anyone can give me some advice about the algorithm of the hash router. > I test id(1,4) go to shard1 (2,3) go to shard2. What is the algorithm ? > > Thanks a lot. > > -----邮件原件----- > 发件人: Mark Miller [mailto:markrmil...@gmail.com] > 发送时间: 2013年2月21日 10:55 > 收件人: solr-user@lucene.apache.org > 主题: Re: solr shards > > > On Feb 20, 2013, at 9:47 PM, Rollin.R.Ma (lab.sh04.Newegg) 41099 < > rollin.r...@newegg.com> wrote: > > > I also see " Concerning CloudSolrServer, there is a JIRA to make it hash > and send updates to the "right" leader, but currently it still doesn't - it > just favors leaders in general over non leaders currently. " > > > > I wonder if one commit to only one leader, not every doc to different > leaders according the shards. > > > That's just an optimization. Updates are forwarded to the right now no > matter which you originally send them to. > > - Mark >