0

I set up a two servers Solr cluster with SolrCloud. Currently I have Master and Replica.

I want to dataimports go to the leader since it doesn't make any sense to make delta-imports on slave (updates wouldn't be distributed to the leader).

From the documentation I get that CloudSolrServer knows cluster state (obtained from Zookeeper) and by default sends all updates only to the leader.

What I want is to make CloudSolrServer to send all dataimport commands to the master. I have the following code:

        SolrServer solrServer = new CloudSolrServer("localhost:2181");
        ModifiableSolrParams params = new ModifiableSolrParams();
        params.set("qt", "/dataimport");
        params.set("command", "delta-import");
        QueryResponse response = solrServer.query(params);

But I see that the requests still goes to both my servers localhost:8080 and localhost:8983. Is there any way to fix this?

Igor Kustov
  • 787
  • 1
  • 8
  • 21

2 Answers2

0

Just replace your solr server initialization to below

SolrServer solrServer = new CloudSolrServer("zkHost1:port,zkHost2:port");

THis will cause the solr server client to consult zookeeper for solrcloud state. For more details read CloudSolrServer documentation to init from zookeeper ensemble.

-2

try { CloudSolrServer css = new CloudSolrServer("host1:2181,host2:2181"); css.connect(); ZkStateReader zkSR2 = css.getZkStateReader(); String leader = zkSR2.getLeaderUrl("collection_name", "shard1", 10); } catch (KeeperException e) { } catch (IOException
e) { } catch (InterruptedException e) {}