Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
89549ae
Simplify how we call AbstractUpdateRequest
epugh Jan 17, 2026
dbcc659
Add change log
epugh Jan 17, 2026
2851911
An optimize always shrinks down the number of segments, unlike commit.
epugh Jan 18, 2026
7b640ce
Remove waitFlush from streaming CommitStream
epugh Jan 18, 2026
aab7414
Updates for a world with out waitFlush
epugh Jan 19, 2026
a5afe1c
Deprecate the commit/optimize methods with lots of parameters in favo…
epugh Jan 19, 2026
076ec1b
clarify that we don't have waitFlush
epugh Jan 19, 2026
1e81280
Simplify calls by using default settings
epugh Jan 19, 2026
27d56eb
attempt to fix checks
epugh Jan 19, 2026
8bd3b42
clean up tags
epugh Jan 19, 2026
158d48b
respond to copilot fixups
epugh Jan 19, 2026
52e1d58
simplify by using default
epugh Jan 19, 2026
90d2962
Use defaults
epugh Jan 19, 2026
535f54f
lint
epugh Jan 19, 2026
94efb38
respond to feedback
epugh Jan 23, 2026
73b924e
Swap CommitOptions to Java Record
epugh Jan 24, 2026
a3b3f76
Simplify where logic lives
epugh Jan 24, 2026
6850c44
Think through what tests we actually need.
epugh Jan 24, 2026
2480bcc
Responding to feedback auditing calls. Remove withPattern
epugh Jan 28, 2026
049e201
Simplify calls to leverage existing defaults
epugh Jan 28, 2026
f830fd2
Merge remote-tracking branch 'upstream/main' into SOLR-7003-v2
epugh Jan 31, 2026
67c8a10
Update to use CommitOoptions
epugh Jan 31, 2026
cbcf8d8
lint
epugh Jan 31, 2026
8b64e24
Fix warning
epugh Jan 31, 2026
78861bd
review javadocs a bit more
epugh Jan 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions changelog/unreleased/SOLR-7003.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc
title: Refactor passing commit options through SolrClient. Remove unused waitFlush parameter.
type: changed # added, changed, fixed, deprecated, removed, dependency_update, security, other
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate the name of this enum. "changed" is so generic that it would seem to apply to anything. "other" is for refactoring.
CC @janhoy seen this issue multiple times now

authors:
- name: Eric Pugh
links:
- name: SOLR-7003
url: https://issues.apache.org/jira/browse/SOLR-7003
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.jetty.HttpJettySolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.CommitOptions;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.request.SolrQuery;
import org.apache.solr.client.solrj.request.UpdateRequest;
Expand Down Expand Up @@ -371,7 +372,7 @@ public void index(String collection, Docs docs, int docCount, boolean parallel)
log("committing data ...");
UpdateRequest commitRequest = new UpdateRequest();
final var url = nodes.get(random.nextInt(cluster.getJettySolrRunners().size()));
commitRequest.setAction(UpdateRequest.ACTION.COMMIT, false, true);
commitRequest.setAction(UpdateRequest.ACTION.COMMIT, CommitOptions.forHardCommit());
client.requestWithBaseUrl(url, commitRequest, collection);
log("done committing data");
} else {
Expand Down Expand Up @@ -501,7 +502,8 @@ public void forceMerge(String collection, int maxMergeSegments) throws Exception

UpdateRequest optimizeRequest = new UpdateRequest();
final var url = nodes.get(random.nextInt(cluster.getJettySolrRunners().size()));
optimizeRequest.setAction(UpdateRequest.ACTION.OPTIMIZE, false, true, maxMergeSegments);
optimizeRequest.setAction(
UpdateRequest.ACTION.OPTIMIZE, CommitOptions.forOptimize(maxMergeSegments));
client.requestWithBaseUrl(url, optimizeRequest, collection);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.jetty.HttpJettySolrClient;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
import org.apache.solr.client.solrj.request.CommitOptions;
import org.apache.solr.client.solrj.request.CoreAdminRequest.WaitForState;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.common.SolrException;
Expand Down Expand Up @@ -305,7 +306,8 @@ private void commitOnLeader(String leaderBaseUrl, String coreName)
ureq.getParams().set(UpdateParams.OPEN_SEARCHER, false);
// If the leader is readOnly, do not fail since the core is already committed.
ureq.getParams().set(UpdateParams.FAIL_ON_READ_ONLY, false);
ureq.setAction(AbstractUpdateRequest.ACTION.COMMIT, false, true).process(client);
ureq.setAction(AbstractUpdateRequest.ACTION.COMMIT, CommitOptions.forHardCommit())
.process(client);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.jetty.HttpJettySolrClient;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
import org.apache.solr.client.solrj.request.CommitOptions;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.response.UpdateResponse;
import org.apache.solr.cloud.DistributedClusterStateUpdater;
Expand Down Expand Up @@ -260,7 +261,7 @@ private static UpdateResponse softCommit(
HttpJettySolrClient solrClient, String baseUrl, String coreName)
throws SolrServerException, IOException {
UpdateRequest ureq = new UpdateRequest();
ureq.setAction(AbstractUpdateRequest.ACTION.COMMIT, false, true, true);
ureq.setAction(AbstractUpdateRequest.ACTION.COMMIT, CommitOptions.forSoftCommit());
return ureq.processWithBaseUrl(solrClient, baseUrl, coreName);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static void addExperimentalFormatWarning(SolrQueryResponse rsp) {

/**
* Check the request parameters and decide if it should commit or optimize. If it does, it will
* check other related parameters such as "waitFlush" and "waitSearcher"
* check other related parameters such as "waitSearcher".
*/
public static boolean handleCommit(
SolrQueryRequest req, UpdateRequestProcessor processor, SolrParams params, boolean force)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.CommitOptions;
import org.apache.solr.client.solrj.request.SolrQuery;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.cloud.ZkConfigSetService;
Expand Down Expand Up @@ -1026,7 +1027,7 @@ protected Map<Object, Throwable> indexSampleDocs(
// load sample docs from blob store
CloudSolrClient cloudSolrClient = cloudClient();
cloudSolrClient.deleteByQuery(collectionName, "*:*", 1);
cloudSolrClient.optimize(collectionName, true, true, 1);
cloudSolrClient.optimize(collectionName);

final int commitWithin = 100;
final int numDocs = docs.size();
Expand Down Expand Up @@ -1060,8 +1061,7 @@ protected Map<Object, Throwable> indexSampleDocs(
}
}

cloudSolrClient.commit(collectionName, true, true, true);

cloudSolrClient.commit(collectionName, CommitOptions.forSoftCommit());
if (!errorsDuringIndexing.isEmpty()) {
return errorsDuringIndexing;
}
Expand All @@ -1084,7 +1084,7 @@ protected long waitToSeeSampleDocs(String collectionName, long numAdded)
// wait up to 5 seconds for this to occur
final long deadline = System.nanoTime() + TimeUnit.SECONDS.toNanos(5);
do {
cloudSolrClient.commit(collectionName, true, true, true);
cloudSolrClient.commit(collectionName, CommitOptions.forSoftCommit());
queryResponse = cloudSolrClient.query(collectionName, query);
numFound = queryResponse.getResults().getNumFound();
if (numFound >= numAdded) {
Expand Down
16 changes: 10 additions & 6 deletions solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.ConcurrentUpdateBaseSolrClient;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
import org.apache.solr.client.solrj.request.CommitOptions;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.response.JavaBinResponseParser;
import org.apache.solr.common.SolrException;
Expand Down Expand Up @@ -293,14 +294,17 @@ public void blockAndDoRetries() throws IOException {

void addCommit(UpdateRequest ureq, CommitUpdateCommand cmd) {
if (cmd == null) return;

CommitOptions options =
CommitOptions.commit(cmd.softCommit)
.waitSearcher(cmd.waitSearcher)
.openSearcher(cmd.openSearcher)
.expungeDeletes(cmd.expungeDeletes)
.maxOptimizeSegments(cmd.maxOptimizeSegments);

ureq.setAction(
cmd.optimize ? AbstractUpdateRequest.ACTION.OPTIMIZE : AbstractUpdateRequest.ACTION.COMMIT,
false,
cmd.waitSearcher,
cmd.maxOptimizeSegments,
cmd.softCommit,
cmd.expungeDeletes,
cmd.openSearcher);
options);
}

private void submit(final Req req, boolean isCommit) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.solr;

import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
import static org.apache.solr.client.solrj.request.AbstractUpdateRequest.ACTION;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
Expand All @@ -26,7 +27,7 @@
import org.apache.commons.io.file.PathUtils;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest.ACTION;
import org.apache.solr.client.solrj.request.CommitOptions;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.client.solrj.request.SolrQuery;
import org.apache.solr.client.solrj.request.UpdateRequest;
Expand All @@ -53,7 +54,7 @@ public void testStopwordsAfterCoreReload() throws Exception {
// default stopwords - stopworda and stopwordb

UpdateRequest up = new UpdateRequest();
up.setAction(ACTION.COMMIT, true, true);
up.setAction(ACTION.COMMIT, CommitOptions.forHardCommit());
up.add(doc);
up.process(getSolrCore());

Expand Down
3 changes: 2 additions & 1 deletion solr/core/src/test/org/apache/solr/cli/ApiToolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.lucene.tests.util.TestUtil;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.CommitOptions;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.cloud.SolrCloudTestCase;
import org.apache.solr.common.params.ModifiableSolrParams;
Expand Down Expand Up @@ -66,7 +67,7 @@ public void testQueryResponse() throws Exception {
cluster.waitForActiveCollection(COLLECTION_NAME, 2, 2);

UpdateRequest ur = new UpdateRequest();
ur.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
ur.setAction(AbstractUpdateRequest.ACTION.COMMIT, CommitOptions.forHardCommit());

for (int i = 0; i < docCount; i++) {
ur.add(
Expand Down
6 changes: 4 additions & 2 deletions solr/core/src/test/org/apache/solr/cli/TestExportTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.solr.client.solrj.jetty.HttpJettySolrClient;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.CommitOptions;
import org.apache.solr.client.solrj.request.JavaBinUpdateRequestCodec;
import org.apache.solr.client.solrj.request.SolrQuery;
import org.apache.solr.client.solrj.request.UpdateRequest;
Expand Down Expand Up @@ -90,7 +91,7 @@ public void testBasic() throws Exception {
Path baseDir = cluster.getBaseDir();

UpdateRequest ur = new UpdateRequest();
ur.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
ur.setAction(AbstractUpdateRequest.ACTION.COMMIT, CommitOptions.forHardCommit());
int docCount = 1000;

for (int i = 0; i < docCount; i++) {
Expand Down Expand Up @@ -194,7 +195,8 @@ public void testVeryLargeCluster() throws Exception {
for (int j = 0; j < 4; j++) {
int bsz = 10000;
UpdateRequest ur = new UpdateRequest();
ur.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true);
ur.setAction(
AbstractUpdateRequest.ACTION.COMMIT, CommitOptions.forHardCommit().waitSearcher(true));
for (int i = 0; i < bsz; i++) {
ur.add(
"id",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private static void initSyncVars() {
@Test
public void testParallelOk() throws Exception {
initSyncVars();
COLLECTION_CLIENT.commit(true, true);
COLLECTION_CLIENT.commit();
assertEquals(0, countdown.getCount());
assertEquals(expectCount, countup.get());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.List;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
import org.apache.solr.client.solrj.request.CommitOptions;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.cloud.Replica;
Expand Down Expand Up @@ -88,7 +89,10 @@ public void test() throws Exception {

// soft-commit so searchers are open on un-committed but flushed segment files
AbstractUpdateRequest request =
new UpdateRequest().setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true, true);
new UpdateRequest()
.setAction(
AbstractUpdateRequest.ACTION.COMMIT,
CommitOptions.forSoftCommit().waitSearcher(true));
cloudClient.request(request);

Replica notLeader = ensureAllReplicasAreActive(DEFAULT_COLLECTION, "shard1", 1, 2, 30).get(0);
Expand Down
4 changes: 2 additions & 2 deletions solr/core/src/test/org/apache/solr/cloud/RouteFieldTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ public void routeFieldTest() throws Exception {
cluster.getSolrClient().add(COLL_ROUTE, docsRoute);
cluster.getSolrClient().add(COLL_ID, docsId);

cluster.getSolrClient().commit(COLL_ROUTE, true, true);
cluster.getSolrClient().commit(COLL_ID, true, true);
cluster.getSolrClient().commit(COLL_ROUTE);
cluster.getSolrClient().commit(COLL_ID);

checkShardsHaveSameDocs();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void testCustomCollectionsAPI() throws Exception {
.getNumFound());

cluster.getSolrClient().deleteByQuery(collection, "*:*");
cluster.getSolrClient().commit(collection, true, true);
cluster.getSolrClient().commit(collection);
assertEquals(
0,
cluster.getSolrClient().query(collection, new SolrQuery("*:*")).getResults().getNumFound());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public void testIndexOptimization() throws Exception {
}

// Optimize the index.
leaderClient.optimize(true, true, 1);
leaderClient.optimize();

// After invoking optimize command, verify that the index directory contains multiple commits
// (including the one we snapshotted earlier).
Expand Down Expand Up @@ -270,7 +270,7 @@ public void testIndexOptimization() throws Exception {
}

// Optimize the index.
leaderClient.optimize(true, true, 1);
leaderClient.optimize();

// Verify that the index directory contains only 1 index commit (which is not the same as the
// snapshotted commit).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,15 +441,15 @@ public void doTestReplicateAfterWrite2Follower() throws Exception {
// higher than that of the leader, just to make the test harder.

index(followerClient, "id", 551, "name", "name = " + 551);
followerClient.commit(true, true);
followerClient.commit();
index(followerClient, "id", 552, "name", "name = " + 552);
followerClient.commit(true, true);
followerClient.commit();
index(followerClient, "id", 553, "name", "name = " + 553);
followerClient.commit(true, true);
followerClient.commit();
index(followerClient, "id", 554, "name", "name = " + 554);
followerClient.commit(true, true);
followerClient.commit();
index(followerClient, "id", 555, "name", "name = " + 555);
followerClient.commit(true, true);
followerClient.commit();

// this doc is added to follower, so it should show an item w/ that result
assertEquals(1, numFound(rQuery(1, "id:555", followerClient)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ private long indexDocs(SolrClient client, int totalDocs, int start) throws Excep
for (int i = 0; i < totalDocs; i++)
ReplicationTestHelper.index(
client, "id", i + start, "name", TestUtil.randomSimpleString(random(), 1000, 5000));
client.commit(true, true);
client.commit();
QueryResponse response =
client.query(
new SolrQuery()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void test() throws Exception {
}
MiniSolrCloudCluster cluster = entry.getValue();
cluster.getSolrClient().add(COLLECTION_NAME, docs);
cluster.getSolrClient().commit(COLLECTION_NAME, true, true);
cluster.getSolrClient().commit(COLLECTION_NAME);

// test using ClusterState elements
assertThat(
Expand Down
4 changes: 2 additions & 2 deletions solr/core/src/test/org/apache/solr/pkg/TestPackages.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public void testPluginLoading() throws Exception {
ur.add(new SolrInputDocument("id", "1"));
ur.setParam("processor", "myurp");
ur.process(cluster.getSolrClient(), COLLECTION_NAME);
cluster.getSolrClient().commit(COLLECTION_NAME, true, true);
cluster.getSolrClient().commit(COLLECTION_NAME);

QueryResponse result = cluster.getSolrClient().query(COLLECTION_NAME, new SolrQuery("id:1"));

Expand Down Expand Up @@ -396,7 +396,7 @@ public void testPluginLoading() throws Exception {
ur.add(new SolrInputDocument("id", "2"));
ur.setParam("processor", "myurp");
ur.process(cluster.getSolrClient(), COLLECTION_NAME);
cluster.getSolrClient().commit(COLLECTION_NAME, true, true);
cluster.getSolrClient().commit(COLLECTION_NAME);

result = cluster.getSolrClient().query(COLLECTION_NAME, new SolrQuery("id:2"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ public void testSortableTextFieldWithAnalyzer() throws Exception {
public void testAddNewFieldAndQuery() throws Exception {
getSolrClient().add(Arrays.asList(sdoc("id", "1", "term_s", "tux")));

getSolrClient().commit(true, true);
getSolrClient().commit();
Map<String, Object> attrs = new HashMap<>();
attrs.put("name", "newstringtestfield");
attrs.put("type", "string");
Expand Down
Loading