You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "dsmiley (via GitHub)" <gi...@apache.org> on 2026/02/06 05:26:33 UTC

[PR] SOLR-18101: SolrJ commit options, fluent API [solr]

dsmiley opened a new pull request, #4109:
URL: https://github.com/apache/solr/pull/4109

   This is a little bit of an API refresh on UpdateRequest/AbstractUpdateRequest to make it clearer how to send various commit options, and their relation to optimize & expungeDeletes.
   
   https://issues.apache.org/jira/browse/SOLR-18101


-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18101: SolrJ commit options, fluent API [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #4109:
URL: https://github.com/apache/solr/pull/4109#discussion_r3428077844


##########
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 {

Review Comment:
   I've been thinking of the soft vs hard matter and I would rather our users not know much about soft vs hard; IMO it should be automatic, with the option to be explicit if you _really_ want to.  Most commits should become soft due to the updateLog.  Not when optimize or expungeDeletes.  Not if there's no updateLog at all.  
   A recent post on our lists show that the soft vs hard commit made a huge difference for their tests... and I suspect it would improve our tests significantly too.



-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18101: SolrJ commit options, fluent API [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #4109:
URL: https://github.com/apache/solr/pull/4109#discussion_r3428033994


##########
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);

Review Comment:
   I dropped the enum altogether



-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18101: SolrJ commit options, fluent API [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #4109:
URL: https://github.com/apache/solr/pull/4109#discussion_r2867526184


##########
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,

Review Comment:
   To be clear, the very explicit decision I made to use this casing is to align with the parameter names they correspond to.



-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18101: SolrJ commit options, fluent API [solr]

Posted by "github-actions[bot] (via GitHub) via issues" <is...@solr.apache.org>.
github-actions[bot] commented on PR #4109:
URL: https://github.com/apache/solr/pull/4109#issuecomment-6618816745

   This PR has had no activity for 60 days and is now labeled as stale.  Any new activity will remove the stale label.  To attract more reviewers, please tag people who might be familiar with the code area and/or notify the dev@solr.apache.org mailing list. To exempt this PR from being marked as stale, make it a draft PR or add the label "exempt-stale". If left unattended, this PR will be closed after another 60 days of inactivity. Thank you for your contribution!


-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18101: SolrJ commit options, fluent API [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #4109:
URL: https://github.com/apache/solr/pull/4109#issuecomment-3858071780

   This is a draft, not using the API just showing what I think it should be and what I want to deprecate.


-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18101: SolrJ commit options, fluent API [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #4109:
URL: https://github.com/apache/solr/pull/4109#discussion_r2867524916


##########
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,

Review Comment:
   I confess I'm annoyed with the collective set of people (whoever they are; I don't care) that started making all-caps a defacto convention standard.  Do they get paid by the lines of code they write?  Do we need silly conversion methods between the all-caps and corresponding natural params they are supposed to map to?



-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18101: SolrJ commit options, fluent API [solr]

Posted by "gerlowskija (via GitHub) via issues" <is...@solr.apache.org>.
gerlowskija commented on code in PR #4109:
URL: https://github.com/apache/solr/pull/4109#discussion_r3391920367


##########
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,

Review Comment:
   I don't have any particular love for the convention, but it's so ubiquitous that I think not following it will be confusing to readers.
   
   Not gonna -1 this PR or anything, but esp. on something 'public' I'd advise reconsideration.



##########
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:
   I see.  I guess in my head the commit required before an optimize or an expungeDelete is more of an implementation detail than something significant worth advertising to users.  But fair enough.



-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18101: SolrJ commit options, fluent API [solr]

Posted by "epugh (via GitHub)" <gi...@apache.org>.
epugh commented on PR #4109:
URL: https://github.com/apache/solr/pull/4109#issuecomment-3861085054

   Seems fine..   I'll be honest, I don't think I have strong opinons around this area...   I almost never use SolrJ in my real world work, I only ever interact with it inside of Solr...   I'm mostly in favour of anything that moves us forward, gets rid of waitFlush, and let's me remove more deprecated code in main.   I may also just be a bit fatigued around all the change/discussion/work in the Java SolrCLient world ;-)!   Not very helpful, I know.


-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18101: SolrJ commit options, fluent API [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #4109:
URL: https://github.com/apache/solr/pull/4109#discussion_r3428036824


##########
solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java:
##########
@@ -166,14 +171,32 @@ public UpdateRequest deleteById(String id) {
     return this;
   }
 
+  /**
+   * For deleting a doc, and identifying the correct shard via a {@code _route_}. For a typical
+   * collection ({@code compositeId} router and without {@code router.field} specified), there's no
+   * need for this since Solr knows the correct shard using only the "id". Otherwise, and without a
+   * route, Solr blasts this out to all shards, which is suboptimal.
+   *
+   * @param route a {@code _route_} for this document
+   */
   public UpdateRequest deleteById(String id, String route) {
     return deleteById(id, route, null);
   }
 
+  /**

Review Comment:
   Thanks... that has been almost half my effort, to include researching the finer points.



-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18101: SolrJ commit options, fluent API [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #4109:
URL: https://github.com/apache/solr/pull/4109#discussion_r2867529494


##########
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);

Review Comment:
   This constant is scoped inside the CommitOption, thus CommitOption.DEFAULTS.



-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18101: SolrJ commit options, fluent API [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #4109:
URL: https://github.com/apache/solr/pull/4109#issuecomment-4931096933

   I want to move along here.  Once the API is validated/reviewed, I want to update the callers of the methods I deprecated to call the non-deprecated methods.


-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18101: SolrJ commit options, fluent API [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #4109:
URL: https://github.com/apache/solr/pull/4109#discussion_r2867532007


##########
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);

Review Comment:
   speaking of enum capitalization... my choice allows me to skip referencing UpdateParams constants and instead take the enum name itself as-is.  I didn't do that... maybe I should.  OTH, I often do a find-usages on canonical constants to see where we reference them.



-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18101: SolrJ commit options, fluent API [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #4109:
URL: https://github.com/apache/solr/pull/4109#discussion_r3428055895


##########
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);

Review Comment:
   Removed the enum and thus this EnumSet it in the latest version.



-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18101: SolrJ commit options, fluent API [solr]

Posted by "gerlowskija (via GitHub) via issues" <is...@solr.apache.org>.
gerlowskija commented on PR #4109:
URL: https://github.com/apache/solr/pull/4109#issuecomment-6632631261

   > I shouldn't delete anything here; but deprecate. Then this could go straight to 9x or 10x. I could also incorporate migrating callers. WDYT @gerlowskija ?
   
   Sorry, catching up on a long review backlog.
   
   +1 to "just" deprecate here and not actually remove anything.  I think migrating a few callers would be nice as it'd give reviewers a sense for whether the new APIs "work" or have some warts that could be improved, but (1) I def don't think that's strictly required and (2) I definitely wouldn't do all of the callsite-migration here.


-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18101: SolrJ commit options, fluent API [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18101: SolrJ commit options, fluent API [solr]

Posted by "gerlowskija (via GitHub)" <gi...@apache.org>.
gerlowskija commented on PR #4109:
URL: https://github.com/apache/solr/pull/4109#issuecomment-4675345594

   Just wanted to "bump" this PR as IMO it'd be a great thing to get in, if you've interest in picking it back up @dsmiley .  (Or alternately if you don't, mention it and maybe I'd pitch in.)  I'd love to see us embrace "fluent" in more places and this would be a good trial of that!


-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] SOLR-18101: SolrJ commit options, fluent API [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #4109:
URL: https://github.com/apache/solr/pull/4109#issuecomment-5543075220

   I shouldn't delete anything here; but deprecate.  Then this could go straight to 9x or 10x.  I could also incorporate migrating callers.  WDYT @gerlowskija ?


-- 
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: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org