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