Hi Ankit,

The following blog posts should help you understand composite-id routing in
SolrCloud better.

http://searchhub.org/2013/06/13/solr-cloud-document-routing/

A more complicated use case (multi-level routing) :
http://searchhub.org/2014/01/06/10590/



On Tue, Sep 2, 2014 at 6:38 AM, Ankit Jain <ankitjainc...@gmail.com> wrote:

> Hi All,
>
> I am using below piece of code to route a data on the basis of user field.
> The data of user1 is going on one shard and data of user2 is going on
> another shard.
>  try {
>             String zkHostString = "127.0.0.1:2181";
>             CloudSolrServer cloudSolrServer = new
> CloudSolrServer(zkHostString);
>             CollectionAdminRequest.createCollection("collection5", 2, 2, 2,
> null, null, "user", cloudSolrServer);
>             cloudSolrServer.setDefaultCollection("collection5");
>
>             for (int i = 0; i <= 100; i++) {
>                 SolrInputDocument document = new SolrInputDocument();
>                 document.addField("id", i);
>                 document.addField("user", "user"+(i%2));
>                 cloudSolrServer.add(document);
>             }
>             cloudSolrServer.commit();
>             cloudSolrServer.shutdown();
>         } catch (SolrException e) {
>             e.printStackTrace();
>         } catch (SolrServerException e) {
>             e.printStackTrace();
>         } catch (IOException e) {
>             e.printStackTrace();
>         }
>
> Now, I  want to use routing at search time. If user search the documents
> for user1, then my query should be execute on only shard1 (shard1 contains
> the data of user1).
>
> Please let me know, how we can route the query to specific shard at search
> time.
>
> --
> Thanks,
> Ankit Jain
>



-- 

Anshum Gupta
http://www.anshumgupta.net

Reply via email to