- Why doesn't a solrj UpdateRequest delete return any shard replication
   factor data?


   - Is there a way to know if/when a solrj UpdateRequest delete has
   achieved replication factor > 1?


When executing a UpdateRequest deleteByQuery with route,
the minAchievedReplicationFactor is always -1. The UpdateRespons contains
no NamedList. See delete code below.

When indexing documents to multiple shards,
the minAchievedReplicationFactor is never > 1. If the shards are iterated,
the first is 2 and the next is 1. Apparently it doesn't wait for all shards
to report.

To ensure consistency in the Solr Cloud the goal is to always ensure the
minAchievedReplicationFactor > 1 so that if the leader dies, the new leader
will be consistent and the remaining replicas can recover to consistent
state.

final UpdateRequest ur = new UpdateRequest();
ur.setParam(UpdateRequest.MIN_REPFACT, "2");
ur.deleteByQuery("cust:b"); // this or fq below works fine
ur.setParam("_route_", "b!"); // so only routed the necessary shard
ur.setParam("json.filter", "cust:b"); // fq more efficient than f
ur.setAction(ACTION.COMMIT, false, true, true); // wait till complete and
visible
UpdateResponse resp = ur.process(solr, "asset");
solr.getShardReplicationFactor(collection,
resp.getResponse()).entrySet().forEach(e -> System.out.println("delete " +
e.getKey() + ":" + e.getValue()));
System.out.println("Delete minRepFactor " +
solr.getMinAchievedReplicationFactor(collection, resp.getResponse()));

I lieu of something cleaner the hack would be to query each replica after
deleting data and after waiting for soft commit and opening a new searcher.

Reply via email to