dsmiley commented on code in PR #4109:
URL: https://github.com/apache/solr/pull/4109#discussion_r2867527652


##########
solr/solrj/src/java/org/apache/solr/client/solrj/request/AbstractUpdateRequest.java:
##########
@@ -26,30 +28,90 @@ public abstract class AbstractUpdateRequest extends 
CollectionRequiringSolrReque
   protected ModifiableSolrParams params = new ModifiableSolrParams(); // maybe 
make final; no setter
   protected int commitWithin = -1;
 
+  public AbstractUpdateRequest(METHOD m, String path) {
+    super(m, path, SolrRequestType.UPDATE);
+  }
+
+  public enum CommitOption {
+    /** Makes the changes visible. True by default. */
+    openSearcher,
+    /** The request should wait for the changes to be visible. True by 
default. */
+    waitSearcher,
+    /** A faster commit that's slightly less durable, and only affects the 
leader replica. */
+    softCommit;
+
+    /** Default standard set of commit options: waitSearcher and openSearcher 
*/
+    public static final EnumSet<CommitOption> DEFAULTS = 
EnumSet.of(waitSearcher, openSearcher);
+  }
+
+  @Deprecated
   public enum ACTION {
     COMMIT,
     OPTIMIZE
   }
 
-  public AbstractUpdateRequest(METHOD m, String path) {
-    super(m, path, SolrRequestType.UPDATE);
+  /**
+   * Solr returns early but schedules a (typically soft) commit. When Solr 
finishes processing the
+   * changes, it will then schedule the next auto soft-commit to occur no 
later than the provided
+   * time interval. Other commit requests and automatic ones may expedite that 
commit to occur
+   * sooner.
+   */
+  public AbstractUpdateRequest commitWithin(int val, TimeUnit unit) {
+    this.commitWithin = Math.toIntExact(unit.toMillis(val));
+    return this;
+  }
+
+  public AbstractUpdateRequest commit() {
+    params.set(UpdateParams.COMMIT, true);
+    return this;
+  }
+
+  /** Commits with additional options. The absense of an option means to 
disable the option. */
+  public AbstractUpdateRequest commit(EnumSet<CommitOption> options) {
+    params.set(UpdateParams.COMMIT, true);
+    // only set if varies from default
+    if (options.contains(CommitOption.softCommit) == true) {
+      params.set(UpdateParams.SOFT_COMMIT, true);
+    }
+    if (options.contains(CommitOption.openSearcher) == false) {
+      params.set(UpdateParams.OPEN_SEARCHER, false);
+      // and don't bother considering waitSearcher as it's irrelevant
+    } else if (options.contains(CommitOption.waitSearcher) == false) {
+      params.set(UpdateParams.WAIT_SEARCHER, false);
+    }
+    return this;
+  }
+
+  public AbstractUpdateRequest commitAndOptimize(EnumSet<CommitOption> 
options, int maxSegments) {

Review Comment:
   It reflects the reality of what's happening.  I recognize the "optimize" or 
"expungeDeletes" are a bigger impact.  I wanted the API here to reflect 
something that was previously non-obvious.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to