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 Udit Tyagi <ud...@gmail.com> on 2016/11/23 10:43:03 UTC

SolrCloud -Distribued Indexing

Hi,

I am a solr user, I am using solr-6.3.0 version, I have some doubts for
Distributed indexing and sharding in SolrCloud pease clarify,

1. How can I index documents to a specific shard(I heard about document
routing not documentation is not proper for that).

I am using solr create command from terminal to create collection i don't
have any option to specify router name while creating collection from
terminal so how can i implement implicit router for my collection.

2.In documentation of Solr-6.3.0 for client API solrj the way to connect to
solrcloud is specified as

String zkHostString = "zkServerA:2181,zkServerB:2181,zkServerC:2181/solr";
SolrClient solr = new
CloudSolrClient.Builder().withZkHost(zkHostString).build();

please update documentation or reply back how can i specify collection name
to
query after connecting to zookeeper.

Any help will be appreciated,Thanks

Regards,
Udit Tyagi

Re: SolrCloud -Distribued Indexing

Posted by Shawn Heisey <ap...@elyograg.org>.
On 11/23/2016 3:43 AM, Udit Tyagi wrote:
> I am a solr user, I am using solr-6.3.0 version, I have some doubts > for Distributed indexing and sharding in SolrCloud pease clarify, > >
1. How can I index documents to a specific shard(I heard about >
document routing not documentation is not proper for that). One of the
really nice things about SolrCloud is the automatic document routing. 
You can shard your index and not worry about which document ends up
where, because SolrCloud will automatically figure that out for you. 
You can turn that off, but aside from time series data (like logs) I
don't see much reason to.

The documentation (link below) says that you can set a _route_ parameter
to name the shard you want to index to.  I have not tried this.  If the
router is implicit and you send a request directly to a replica for the
shard you want to index, then you wouldn't need to name a shard.

https://cwiki.apache.org/confluence/display/solr/Shards+and+Indexing+Data+in+SolrCloud#ShardsandIndexingDatainSolrCloud-DocumentRouting

> I am using solr create command from terminal to create collection i > don't have any option to specify router name while creating >
collection from terminal so how can i implement implicit router for > my
collection.
It looks like you can't specify the router when using the script to
create the collection.  Use the Collections API instead, where you can
make an HTTP call to create the collection.  You can even use a browser
to make the request.  Note that this is what the script actually does
when you create a collection in cloud mode and don't upload a config at
the same time -- it just calls this HTTP api.

https://cwiki.apache.org/confluence/display/solr/Collections+API#CollectionsAPI-api1

> 2.In documentation of Solr-6.3.0 for client API solrj the way to > connect to solrcloud is specified as > > String zkHostString = >
"zkServerA:2181,zkServerB:2181,zkServerC:2181/solr"; SolrClient solr > =
new CloudSolrClient.Builder().withZkHost(zkHostString).build();
Sugar methods on the client like "add" and "query" have alternate forms
that accept the name of a collection as one of the parameters.  If you
are building a request from scratch and not using those sugar methods on
the client, you can set the "collection" parameter on the request.  The
client has a "setDefaultCollection" method that sets the default
collection for requests that don't mention which collection to use.  You
can't use setDefaultCollection if you have assigned the client to a
SolrClient -- it must be a CloudSolrClient.  If you cast it back to the
cloud object, then you'd be able to do it.  This additional line after
the code above would work:

((CloudSolrClient) solr).setDefaultCollection("foo");

Thanks,
Shawn


Re: SolrCloud -Distribued Indexing

Posted by Jerome Yang <je...@pivotal.io>.
Hi,

1. You can usr solr collections api to create collection with "*implicit*"
router.
Please check, CREATE
https://cwiki.apache.org/confluence/display/solr/Collections+API#CollectionsAPI-api1

2. There's several ways to indicate which collection you want send request
to.
    a> setDefaultCollection
    b> sendRequest(SolrRequest request, String collection)
Please check
https://lucene.apache.org/solr/6_1_0/solr-solrj/org/apache/solr/client/solrj/impl/CloudSolrClient.html

Regards,
Jerome


On Wed, Nov 23, 2016 at 6:43 PM, Udit Tyagi <ud...@gmail.com> wrote:

> Hi,
>
> I am a solr user, I am using solr-6.3.0 version, I have some doubts for
> Distributed indexing and sharding in SolrCloud pease clarify,
>
> 1. How can I index documents to a specific shard(I heard about document
> routing not documentation is not proper for that).
>
> I am using solr create command from terminal to create collection i don't
> have any option to specify router name while creating collection from
> terminal so how can i implement implicit router for my collection.
>
> 2.In documentation of Solr-6.3.0 for client API solrj the way to connect to
> solrcloud is specified as
>
> String zkHostString = "zkServerA:2181,zkServerB:2181,zkServerC:2181/solr";
> SolrClient solr = new
> CloudSolrClient.Builder().withZkHost(zkHostString).build();
>
> please update documentation or reply back how can i specify collection name
> to
> query after connecting to zookeeper.
>
> Any help will be appreciated,Thanks
>
> Regards,
> Udit Tyagi
>