You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by "Rollin.R.Ma (lab.sh04.Newegg) 41099" <Ro...@newegg.com> on 2013/02/21 03:47:50 UTC
答复: solr shards
Hi
I user below code is right:
SolrInputDocument doc1 = new SolrInputDocument();
doc1.addField("id", "1");
doc1.addField("name", "11s");
SolrInputDocument doc2 = new SolrInputDocument();
doc2.addField("id", "2");
doc2.addField("name", "22s");
SolrInputDocument doc3 = new SolrInputDocument();
doc3.addField("id", "3");
doc3.addField("name", "33s");
SolrInputDocument doc11 = new SolrInputDocument();
doc11.addField("id", "14");
doc11.addField("name", "44s");
Collection<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
docs.add(doc1);
solrServer.add(docs);
solrServer.optimize();
solrServer.commit();
docs.clear();
docs.add(doc2);
solrServer.add(docs);
solrServer.optimize();
solrServer.commit();
docs.clear();
docs.add(doc3);
solrServer.add(docs);
solrServer.optimize();
solrServer.commit();
docs.clear();
docs.add(doc11);
solrServer.add(docs);
solrServer.optimize();
solrServer.commit();
But use below code is not right:
SolrInputDocument doc1 = new SolrInputDocument();
doc1.addField("id", "1");
doc1.addField("name", "11s");
SolrInputDocument doc2 = new SolrInputDocument();
doc2.addField("id", "2");
doc2.addField("name", "22s");
SolrInputDocument doc3 = new SolrInputDocument();
doc3.addField("id", "3");
doc3.addField("name", "33s");
SolrInputDocument doc11 = new SolrInputDocument();
doc11.addField("id", "14");
doc11.addField("name", "44s");
Collection<SolrInputDocument> docs = new ArrayList<SolrInputDocument>();
docs.add(doc1);
docs.add(doc2);
docs.add(doc3);
docs.add(doc11);
solrServer.add(docs);
solrServer.optimize();
solrServer.commit();
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.
Thanks!
-----邮件原件-----
发件人: Mark Miller [mailto:markrmiller@gmail.com]
发送时间: 2013年2月21日 10:38
收件人: solr-user@lucene.apache.org
主题: Re: solr shards
Can you give some more details? When you look at the cloud tab of the admin UI, does the cluster visualization look right? Are all the nodes green? Perhaps the shard is a leader and a replica single shrad and you just think it's 2 shards?
- Mark
On Feb 20, 2013, at 8:26 PM, rulinma <ru...@gmail.com> wrote:
> Hi
> Use SolrCloud4.1 with one collection and 2 shards.
>
> I add 4 docs with id(1,2,3,4) set. I found that they appeard in
> shard1 or
> shard2 together, not (1,3) in shard1 and (2,4) in shard2, I want to
> know why? who can give me some advice.
>
> Thanks!
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/solr-shards-tp4041704.html
> Sent from the Solr - User mailing list archive at Nabble.com.
Re: 答复: solr shards
Posted by rulinma <ru...@gmail.com>.
I give some comments to this tompic:
1 compoisteId with setting numshards
1.1 uinique id (hash alogrith to set shard)
1.2 espically, prefix with "!" will be route to same shard if you set
"xxxx!yyyy" in id
2 not set numshars
2.1 user using "_field_"(schema.xml) to set where to sink data in shard
2.2 use ip to insert local
In addition, if you set numshards with _field at the same time ,
compositerId will be used only.
Thanks.
--
View this message in context: http://lucene.472066.n3.nabble.com/solr-shards-tp4041704p4042903.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: 答复: solr shards
Posted by Erick Erickson <er...@gmail.com>.
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.Ma@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:markrmiller@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.Ma@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
>
答复: solr shards
Posted by "Rollin.R.Ma (lab.sh04.Newegg) 41099" <Ro...@newegg.com>.
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:markrmiller@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 <Ro...@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
Re: solr shards
Posted by Mark Miller <ma...@gmail.com>.
On Feb 20, 2013, at 9:47 PM, Rollin.R.Ma (lab.sh04.Newegg) 41099 <Ro...@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