You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ab...@apache.org on 2026/10/08 08:45:09 UTC
(solr) branch branch_10_1 updated (988214d2bc5 -> 02d093afcfa)
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a change to branch branch_10_1
in repository https://gitbox.apache.org/repos/asf/solr.git
from 988214d2bc5 Ref guide, major-changes-in-solr-9.adoc: 9.11
new 35900752459 SOLR-10198: EmbeddedSolrServer StreamingResponseCallback: to SolrJ-native types. (#4965)
new 16c89f928e2 SOLR-13202: Return 400 instead of 500 for join queries missing from/to parameters (#5012)
new 8596906fb00 SOLR-18124: Add tracing spans for UpdateLog replay (#4962)
new 96eadd9d247 SOLR-18124: Trace index replication with a span (#4963)
new cffb9012cda SOLR-18504: Merge duplicate OpenAPI path templates (#5024)
new a61ac63ab0a Test fix: TestCollapseQParserPlugin
new 45cbb3ae55c SOLR-18508: {!auxIndexJoin} prune join-index column via `[to-min..to-max]` range (#5033)
new 295bd6c57ef SOLR-18124: Trace RecoveryStrategy with a span and events (#4961)
new f72a4a9c705 Fix incorrect v2 API examples in the Schema API ref guide (#4942)
new 02d093afcfa SOLR-18493: Rename Index & Query section in new admin UI (#4994)
The 10 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
changelog/unreleased/SOLR-10198.yml | 7 +
changelog/unreleased/SOLR-13202.yml | 7 +
.../SOLR-18124-updatelog-replay-tracing.yml | 9 +
.../SOLR-18493-rename-index-query-new-ui.yml | 7 +
.../SOLR-18504-duplicate-path-templates.yml | 10 ++
...8508-auxIndexJoin-skip-out-of-range-columns.yml | 11 ++
solr/api/build.gradle | 24 +++
.../client/api/endpoint/ClusterFileStoreApis.java | 4 +-
.../solr/client/api/endpoint/GetSchemaApi.java | 5 +-
.../client/solrj/embedded/EmbeddedSolrServer.java | 13 +-
.../org/apache/solr/cloud/RecoveryStrategy.java | 54 +++++-
.../java/org/apache/solr/handler/IndexFetcher.java | 8 +
.../apache/solr/handler/ReplicationHandler.java | 24 ++-
.../solr/handler/admin/api/GetSchemaField.java | 10 +-
.../org/apache/solr/response/DocsStreamer.java | 89 ++++++++++
.../org/apache/solr/search/JoinQParserPlugin.java | 2 +
.../search/join/AuxIndexJoinQParserPlugin.java | 4 +-
.../search/join/CrossCollectionJoinQParser.java | 1 +
.../solr/search/join/ScoreJoinQParserPlugin.java | 13 ++
.../join/auxindexjoin/JoinIndexScorerSupplier.java | 92 +++++++---
.../src/java/org/apache/solr/update/UpdateLog.java | 45 ++++-
solr/core/src/test/org/apache/solr/TestJoin.java | 15 ++
.../TestEmbeddedSolrServerStreamingTypes.java | 186 +++++++++++++++++++++
.../tagger/EmbeddedSolrNoSerializeTest.java | 3 +-
.../solr/search/TestCollapseQParserPlugin.java | 3 +
.../search/join/CrossCollectionJoinQueryTest.java | 23 +++
.../search/join/TestAuxIndexJoinQParserPlugin.java | 11 +-
.../search/join/TestGlobalOrdinalsJoinQParser.java | 13 ++
.../modules/indexing-guide/pages/schema-api.adoc | 82 ++++-----
.../commonMain/composeResources/values/strings.xml | 2 +-
.../main/integration/DefaultMainComponent.kt | 4 +-
.../apache/solr/ui/views/navigation/MainMenu.kt | 2 +-
.../solr/ui/views/navigation/NavigationSideBar.kt | 6 +-
33 files changed, 696 insertions(+), 93 deletions(-)
create mode 100644 changelog/unreleased/SOLR-10198.yml
create mode 100644 changelog/unreleased/SOLR-13202.yml
create mode 100644 changelog/unreleased/SOLR-18124-updatelog-replay-tracing.yml
create mode 100644 changelog/unreleased/SOLR-18493-rename-index-query-new-ui.yml
create mode 100644 changelog/unreleased/SOLR-18504-duplicate-path-templates.yml
create mode 100644 changelog/unreleased/SOLR-18508-auxIndexJoin-skip-out-of-range-columns.yml
create mode 100644 solr/core/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServerStreamingTypes.java
(solr) 03/10: SOLR-18124: Add tracing spans for UpdateLog replay (#4962)
Posted by ab...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch branch_10_1
in repository https://gitbox.apache.org/repos/asf/solr.git
commit 8596906fb00d7d8028cd07681aa97dc6a7321312
Author: David Smiley <ds...@apache.org>
AuthorDate: Wed Oct 7 14:26:25 2026 -0400
SOLR-18124: Add tracing spans for UpdateLog replay (#4962)
Co-authored-by: Kamlendra <ka...@gmail.com>
Co-authored-by: openworld-maker <26...@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <no...@anthropic.com>
(cherry picked from commit 4aaf68b40fb08b867fe865892d295fc1502afefc)
(cherry picked from commit 394a1e28ad7a28b1422fe96d7e8354006469fb49)
---
.../SOLR-18124-updatelog-replay-tracing.yml | 9 +++++
.../src/java/org/apache/solr/update/UpdateLog.java | 45 +++++++++++++++++++++-
2 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/changelog/unreleased/SOLR-18124-updatelog-replay-tracing.yml b/changelog/unreleased/SOLR-18124-updatelog-replay-tracing.yml
new file mode 100644
index 00000000000..655aed1a3a4
--- /dev/null
+++ b/changelog/unreleased/SOLR-18124-updatelog-replay-tracing.yml
@@ -0,0 +1,9 @@
+title: Tracing (spans) for replication, recovery, and updatelog replay.
+type: changed
+authors:
+ - name: Gaurav Singh
+ nick: gsingh-code
+ - name: David Smiley
+links:
+ - name: SOLR-18124
+ url: https://issues.apache.org/jira/browse/SOLR-18124
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateLog.java b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
index 2b0f202a4bd..cfe671f36df 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateLog.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
@@ -22,6 +22,8 @@ import static org.apache.solr.update.processor.DistributingUpdateProcessorFactor
import com.carrotsearch.hppc.LongHashSet;
import com.carrotsearch.hppc.LongSet;
import io.opentelemetry.api.common.Attributes;
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.StatusCode;
import java.io.Closeable;
import java.io.IOException;
import java.io.UncheckedIOException;
@@ -93,6 +95,7 @@ import org.apache.solr.util.RefCounted;
import org.apache.solr.util.TestInjection;
import org.apache.solr.util.TimeOut;
import org.apache.solr.util.plugin.PluginInfoInitialized;
+import org.apache.solr.util.tracing.TraceUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -2129,7 +2132,16 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
// setting request info will help logging
SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req, rsp));
- try {
+ final Span span = TraceUtils.getGlobalTracer().spanBuilder("updatelog.replay").startSpan();
+ TraceUtils.ifNotNoop(
+ span,
+ s -> {
+ TraceUtils.setDbInstance(s, req.getCore().getName());
+ s.setAttribute("updatelog.replay.state", state.toString());
+ s.setAttribute("updatelog.replay.logs", translogs.size());
+ });
+ try (var scope = span.makeCurrent()) {
+ assert scope != null; // prevent javac warning about scope being unused
for (; ; ) {
TransactionLog translog = translogs.pollFirst();
if (translog == null) break;
@@ -2143,9 +2155,11 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
recoveryInfo.errors.incrementAndGet();
log.error("Replay failed due to exception", e);
}
+ span.recordException(e);
} catch (Exception e) {
recoveryInfo.errors.incrementAndGet();
log.error("Replay failed due to exception", e);
+ span.recordException(e);
} finally {
// change the state while updates are still blocked to prevent races
state = State.ACTIVE;
@@ -2159,6 +2173,19 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
log.error("ERROR: didn't get to recover from tlog {}", translog);
translog.decref();
}
+
+ TraceUtils.ifNotNoop(
+ span,
+ s -> {
+ s.setAttribute("updatelog.replay.adds", recoveryInfo.adds);
+ s.setAttribute("updatelog.replay.deletes", recoveryInfo.deletes);
+ s.setAttribute("updatelog.replay.deleteByQuery", recoveryInfo.deleteByQuery);
+ s.setAttribute("updatelog.replay.errors", recoveryInfo.errors.get());
+ });
+ if (recoveryInfo.failed || recoveryInfo.errors.get() > 0) {
+ span.setStatus(StatusCode.ERROR);
+ }
+ span.end();
}
loglog.warn("Log replay finished. recoveryInfo={}", recoveryInfo);
@@ -2169,7 +2196,18 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
}
public void doReplay(TransactionLog translog) {
- try {
+ final Span span =
+ TraceUtils.getGlobalTracer().spanBuilder("updatelog.replay.log").startSpan();
+ TraceUtils.ifNotNoop(
+ span,
+ s -> {
+ if (translog.tlog != null) {
+ s.setAttribute("updatelog.replay.logFile", translog.tlog.getFileName().toString());
+ }
+ s.setAttribute("updatelog.replay.logSizeBytes", translog.getLogSize());
+ });
+ try (var scope = span.makeCurrent()) {
+ assert scope != null; // prevent javac warning about scope being unused
loglog.warn(
"Starting log replay {} active={} starting pos={} inSortedOrder={}",
translog,
@@ -2346,10 +2384,12 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
} catch (ClassCastException cl) {
recoveryInfo.errors.incrementAndGet();
loglog.warn("REPLAY_ERR: Unexpected log entry or corrupt log. Entry={}", o, cl);
+ span.recordException(cl);
// would be caused by a corrupt transaction log
} catch (Exception ex) {
recoveryInfo.errors.incrementAndGet();
loglog.warn("REPLAY_ERR: Exception replaying log", ex);
+ span.recordException(ex);
// something wrong with the request?
}
assert TestInjection.injectUpdateLogReplayRandomPause();
@@ -2393,6 +2433,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
} finally {
if (tlogReader != null) tlogReader.close();
translog.decref();
+ span.end();
}
}
(solr) 01/10: SOLR-10198: EmbeddedSolrServer StreamingResponseCallback: to SolrJ-native types. (#4965)
Posted by ab...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch branch_10_1
in repository https://gitbox.apache.org/repos/asf/solr.git
commit 359007524594bb3b653b916fff3e411fc8191f7f
Author: Nick <ni...@gmail.com>
AuthorDate: Wed Oct 7 07:19:32 2026 -0600
SOLR-10198: EmbeddedSolrServer StreamingResponseCallback: to SolrJ-native types. (#4965)
-- instead of Lucene types. Thus a user's callback implementation can be standard whether it's using EmbeddedSolrServer or a normal SolrClient.
(cherry picked from commit e97c2a0884cbd68790fd7e7036fbb7800db27856)
(cherry picked from commit 9ed938a1f7a86fcd405408db2635e9d4ebbb1eb0)
---
changelog/unreleased/SOLR-10198.yml | 7 +
.../client/solrj/embedded/EmbeddedSolrServer.java | 13 +-
.../org/apache/solr/response/DocsStreamer.java | 89 ++++++++++
.../TestEmbeddedSolrServerStreamingTypes.java | 186 +++++++++++++++++++++
.../tagger/EmbeddedSolrNoSerializeTest.java | 3 +-
5 files changed, 293 insertions(+), 5 deletions(-)
diff --git a/changelog/unreleased/SOLR-10198.yml b/changelog/unreleased/SOLR-10198.yml
new file mode 100644
index 00000000000..f10ba33fee6
--- /dev/null
+++ b/changelog/unreleased/SOLR-10198.yml
@@ -0,0 +1,7 @@
+title: "EmbeddedSolrServer StreamingResponseCallback: Normalize Lucene stored fields to SolrJ-native types."
+type: fixed
+authors:
+ - name: Nick Shanin
+links:
+ - name: SOLR-10198
+ url: https://issues.apache.org/jira/browse/SOLR-10198
diff --git a/solr/core/src/java/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java b/solr/core/src/java/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java
index f9489beb73a..e43bbfb5cdc 100644
--- a/solr/core/src/java/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java
+++ b/solr/core/src/java/org/apache/solr/client/solrj/embedded/EmbeddedSolrServer.java
@@ -56,9 +56,11 @@ import org.apache.solr.core.SolrCore;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrRequestHandler;
import org.apache.solr.request.SolrRequestInfo;
+import org.apache.solr.response.DocsStreamer;
import org.apache.solr.response.JavaBinResponseWriter;
import org.apache.solr.response.ResultContext;
import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.schema.IndexSchema;
import org.apache.solr.servlet.SolrRequestParsers;
/**
@@ -292,7 +294,7 @@ public class EmbeddedSolrServer extends SolrClient {
};
// invoke callbacks, and writes the rest to byteBuffer
- try (var javaBinCodec = createJavaBinCodec(callback, resolver)) {
+ try (var javaBinCodec = createJavaBinCodec(callback, resolver, req.getSchema())) {
javaBinCodec.setWritableDocFields(resolver).marshal(rsp.getValues(), byteBuffer);
}
}
@@ -348,12 +350,17 @@ public class EmbeddedSolrServer extends SolrClient {
}
private JavaBinCodec createJavaBinCodec(
- final StreamingResponseCallback callback, final JavaBinResponseWriter.Resolver resolver) {
+ final StreamingResponseCallback callback,
+ final JavaBinResponseWriter.Resolver resolver,
+ final IndexSchema schema) {
return new JavaBinCodec(resolver) {
@Override
public void writeSolrDocument(SolrDocument doc) {
- callback.streamSolrDocument(doc);
+ // The callback receives the document itself, so it bypasses the conversion the
+ // Resolver applies when a document is serialized. Convert stored fields here so
+ // streamed documents carry the same native types as query() results.
+ callback.streamSolrDocument(DocsStreamer.externalizeStoredValues(doc, schema));
// super.writeSolrDocument( doc, fields );
}
diff --git a/solr/core/src/java/org/apache/solr/response/DocsStreamer.java b/solr/core/src/java/org/apache/solr/response/DocsStreamer.java
index 1f7a2e5ac28..7b33cf5800c 100644
--- a/solr/core/src/java/org/apache/solr/response/DocsStreamer.java
+++ b/solr/core/src/java/org/apache/solr/response/DocsStreamer.java
@@ -19,10 +19,14 @@ package org.apache.solr.response;
import static org.apache.solr.schema.FieldType.ExternalizeStoredValuesAsObjects;
import java.io.IOException;
+import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexableField;
@@ -54,9 +58,14 @@ import org.apache.solr.search.DocList;
import org.apache.solr.search.ReturnFields;
import org.apache.solr.search.SolrDocumentFetcher;
import org.apache.solr.search.SolrReturnFields;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/** This streams SolrDocuments from a DocList and applies transformer */
public class DocsStreamer implements Iterator<SolrDocument> {
+ private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final Object FAILED_STORED_VALUE = new Object();
+
/**
* A hardcoded list of known Solr field types that will be trusted to control their own conversion
* of stored field values into external Objects (via {@link FieldType#toObject}) when returning
@@ -186,6 +195,86 @@ public class DocsStreamer implements Iterator<SolrDocument> {
public void remove() { // do nothing
}
+ /**
+ * Replace Lucene {@link IndexableField} values on a {@link SolrDocument} (and nested / child
+ * documents) with the SolrJ-native objects that clients see after JavaBin deserialization. The
+ * serialized JavaBin path already converts stored values through JavaBinResponseWriter.Resolver;
+ * this exists for the EmbeddedSolrServer streaming path, whose codec hands documents straight to
+ * the callback, so {@code queryAndStreamResponse} matches {@code query} / {@code HttpSolrClient}.
+ *
+ * <p>A stored value that cannot be converted is logged and omitted; conversion continues for the
+ * remaining values and fields.
+ *
+ * <p>Do not call this from {@link #convertLuceneDocToSolrDoc}; JSON/XML writers and some
+ * transformers still expect stored fields as {@link IndexableField}.
+ *
+ * @see #getValue(SchemaField, IndexableField)
+ */
+ public static SolrDocument externalizeStoredValues(SolrDocument doc, IndexSchema schema) {
+ if (doc == null || schema == null) {
+ return doc;
+ }
+ List<String> failedFields = null;
+ for (Iterator<Map.Entry<String, Object>> it = doc.iterator(); it.hasNext(); ) {
+ Map.Entry<String, Object> entry = it.next();
+ Object val = entry.getValue();
+ Object converted = externalizeValue(val, schema);
+ if (FAILED_STORED_VALUE.equals(converted)) {
+ // The document's entry iterator does not support remove(), so collect the
+ // failed fields and remove them from the document after the loop instead.
+ if (failedFields == null) {
+ failedFields = new ArrayList<>();
+ }
+ failedFields.add(entry.getKey());
+ } else if (!Objects.equals(converted, val)) {
+ entry.setValue(converted);
+ }
+ }
+ if (failedFields != null) {
+ for (String failedField : failedFields) {
+ doc.remove(failedField);
+ }
+ }
+ List<SolrDocument> children = doc.getChildDocuments();
+ if (children != null) {
+ for (SolrDocument child : children) {
+ externalizeStoredValues(child, schema);
+ }
+ }
+ return doc;
+ }
+
+ private static Object externalizeValue(Object val, IndexSchema schema) {
+ if (val instanceof IndexableField f) {
+ try {
+ return getValue(schema.getFieldOrNull(f.name()), f);
+ } catch (Exception | AssertionError e) {
+ // AssertionError: point field types (IntPointField, DatePointField, ...) throw it
+ // from toObject when a stored value predates a change to a point type.
+ log.warn("Error reading a field : {}", f, e);
+ return FAILED_STORED_VALUE;
+ }
+ }
+ if (val instanceof SolrDocument nested) {
+ return externalizeStoredValues(nested, schema);
+ }
+ if (val instanceof Collection<?> coll) {
+ List<Object> out = new ArrayList<>(coll.size());
+ boolean changed = false;
+ for (Object item : coll) {
+ Object converted = externalizeValue(item, schema);
+ if (FAILED_STORED_VALUE.equals(converted)) {
+ changed = true;
+ continue;
+ }
+ changed |= !Objects.equals(converted, item);
+ out.add(converted);
+ }
+ return changed ? (out.isEmpty() ? FAILED_STORED_VALUE : out) : val;
+ }
+ return val;
+ }
+
public static Object getValue(SchemaField sf, IndexableField f) {
FieldType ft = null;
if (sf != null) {
diff --git a/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServerStreamingTypes.java b/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServerStreamingTypes.java
new file mode 100644
index 00000000000..a77d1cd01fd
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/client/solrj/embedded/TestEmbeddedSolrServerStreamingTypes.java
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.client.solrj.embedded;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.lucene.document.Document;
+import org.apache.lucene.document.StoredField;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexableField;
+import org.apache.solr.SolrTestCase;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.request.SolrQuery;
+import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.client.solrj.response.StreamingResponseCallback;
+import org.apache.solr.common.SolrDocument;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.core.SolrCore;
+import org.apache.solr.schema.IndexSchema;
+import org.apache.solr.util.EmbeddedSolrServerTestRule;
+import org.apache.solr.util.RefCounted;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+
+/**
+ * EmbeddedSolrServer {@code queryAndStreamResponse} must return the same native field types as
+ * {@code query} / HttpSolrClient, not Lucene {@link IndexableField} instances.
+ */
+public class TestEmbeddedSolrServerStreamingTypes extends SolrTestCase {
+
+ @ClassRule
+ public static final EmbeddedSolrServerTestRule solrTestRule = new EmbeddedSolrServerTestRule();
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ solrTestRule.startSolr(SolrTestCaseJ4.TEST_HOME());
+ SolrTestCaseJ4.newRandomConfig();
+ solrTestRule.newCollection().withConfigSet(SolrTestCaseJ4.TEST_COLL1_CONF()).create();
+ }
+
+ @Test
+ public void testQueryAndStreamResponseReturnsNativeFieldTypes() throws Exception {
+ EmbeddedSolrServer server = solrTestRule.getSolrClient("collection1");
+ server.deleteByQuery("*:*");
+ // city_s1 is *_s1: stored string, multiValued=false. schema.xml is version 1.0, so
+ // fields without multiValued="false" (including name) default to multiValued and
+ // query() returns a one-element list. foo_i_p is pint so the native type is Integer.
+ // name is multiValued: streaming must convert each element (Collection branch).
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("id", "1");
+ doc.addField("foo_i_p", 42);
+ doc.addField("city_s1", "Boston");
+ doc.addField("name", "Alice");
+ doc.addField("name", "Bob");
+ server.add(doc);
+ server.commit();
+
+ SolrQuery q = new SolrQuery("*:*");
+ q.setFields("id", "foo_i_p", "city_s1", "name");
+
+ QueryResponse rsp = server.query(q);
+ SolrDocument queried = rsp.getResults().get(0);
+ Object queriedId = queried.getFieldValue("id");
+ Object queriedInt = queried.getFieldValue("foo_i_p");
+ Object queriedName = queried.getFieldValue("city_s1");
+ assertEquals("1", queriedId);
+ assertEquals(Integer.valueOf(42), queriedInt);
+ assertEquals("Boston", queriedName);
+ assertFalse("query() must not leak Lucene stored fields", queriedInt instanceof IndexableField);
+
+ AtomicReference<SolrDocument> streamed = new AtomicReference<>();
+ server.queryAndStreamResponse(
+ q,
+ new StreamingResponseCallback() {
+ @Override
+ public void streamSolrDocument(SolrDocument doc) {
+ streamed.set(doc);
+ }
+
+ @Override
+ public void streamDocListInfo(long numFound, long start, Float maxScore) {
+ assertEquals(1, numFound);
+ }
+ });
+
+ SolrDocument streamedDoc = streamed.get();
+ assertNotNull(streamedDoc);
+ Object streamedId = streamedDoc.getFieldValue("id");
+ Object streamedInt = streamedDoc.getFieldValue("foo_i_p");
+ Object streamedName = streamedDoc.getFieldValue("city_s1");
+ assertFalse(
+ "queryAndStreamResponse must not leak Lucene stored fields",
+ streamedInt instanceof IndexableField);
+ assertEquals(queriedId.getClass(), streamedId.getClass());
+ assertEquals(queriedInt.getClass(), streamedInt.getClass());
+ assertEquals(queriedName.getClass(), streamedName.getClass());
+ assertEquals(queriedId, streamedId);
+ assertEquals(queriedInt, streamedInt);
+ assertEquals(queriedName, streamedName);
+ assertEquals(Integer.class, streamedInt.getClass());
+ assertEquals(String.class, streamedName.getClass());
+ // multi-valued field: both paths return a list of native Strings
+ Object queriedNames = queried.getFieldValue("name");
+ Object streamedNames = streamedDoc.getFieldValue("name");
+ assertTrue(queriedNames instanceof List);
+ assertTrue(streamedNames instanceof List);
+ assertEquals(queriedNames, streamedNames);
+ assertEquals(Arrays.asList("Alice", "Bob"), streamedNames);
+ }
+
+ @Test
+ public void testStreamingOmitsValueWhoseConversionThrowsAssertionError() throws Exception {
+ EmbeddedSolrServer server = solrTestRule.getSolrClient("collection1");
+ server.deleteByQuery("*:*");
+ server.commit();
+
+ // Write a Lucene document directly, bypassing the update pipeline: count_i_p is a
+ // pint field now, but the stored value written here is a string, as if it had been
+ // indexed before the field's type changed to pint. (A pint field the other test in
+ // this class does not use, so the raw field cannot clash with its field metadata.)
+ // IntPointField.toObject throws AssertionError for such a value (it has no numeric
+ // value); that must not fail the whole streamed response. The value is logged and
+ // omitted instead. The other fields are created through the schema so their Lucene
+ // field shapes match documents the update pipeline writes.
+ Document luceneDoc = new Document();
+ luceneDoc.add(new StoredField("count_i_p", "not-a-number"));
+ try (SolrCore core = solrTestRule.getCoreContainer().getCore("collection1")) {
+ IndexSchema schema = core.getLatestSchema();
+ for (IndexableField f : schema.getField("id").createFields("bad1")) {
+ luceneDoc.add(f);
+ }
+ for (IndexableField f : schema.getField("city_s1").createFields("Boston")) {
+ luceneDoc.add(f);
+ }
+ RefCounted<IndexWriter> iwRef = core.getSolrCoreState().getIndexWriter(core);
+ try {
+ iwRef.get().addDocument(luceneDoc);
+ } finally {
+ iwRef.decref();
+ }
+ }
+ server.commit();
+
+ SolrQuery q = new SolrQuery("*:*");
+ q.setFields("id", "count_i_p", "city_s1");
+
+ AtomicReference<SolrDocument> streamed = new AtomicReference<>();
+ server.queryAndStreamResponse(
+ q,
+ new StreamingResponseCallback() {
+ @Override
+ public void streamSolrDocument(SolrDocument doc) {
+ streamed.set(doc);
+ }
+
+ @Override
+ public void streamDocListInfo(long numFound, long start, Float maxScore) {
+ assertEquals(1, numFound);
+ }
+ });
+
+ SolrDocument streamedDoc = streamed.get();
+ assertNotNull("the document must still be streamed", streamedDoc);
+ assertEquals("bad1", streamedDoc.getFieldValue("id"));
+ assertEquals("Boston", streamedDoc.getFieldValue("city_s1"));
+ assertFalse(
+ "the unconvertible value must be omitted, not streamed",
+ streamedDoc.containsKey("count_i_p"));
+ }
+}
diff --git a/solr/core/src/test/org/apache/solr/handler/tagger/EmbeddedSolrNoSerializeTest.java b/solr/core/src/test/org/apache/solr/handler/tagger/EmbeddedSolrNoSerializeTest.java
index ca70f22b066..4f67825f1c6 100644
--- a/solr/core/src/test/org/apache/solr/handler/tagger/EmbeddedSolrNoSerializeTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/tagger/EmbeddedSolrNoSerializeTest.java
@@ -27,7 +27,6 @@ import java.util.Collection;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiFunction;
-import org.apache.lucene.document.Field;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
@@ -142,6 +141,6 @@ public class EmbeddedSolrNoSerializeTest extends SolrTestCaseJ4 {
QueryResponse rsp = req.process(solrServer);
assertNotNull(rsp.getResponse().get("tags"));
assertNotNull(refDoc.get());
- assertEquals("Boston", ((Field) refDoc.get().getFieldValue("name")).stringValue());
+ assertEquals("Boston", refDoc.get().getFieldValue("name"));
}
}
(solr) 07/10: SOLR-18508: {!auxIndexJoin} prune join-index column via `[to-min..to-max]` range (#5033)
Posted by ab...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch branch_10_1
in repository https://gitbox.apache.org/repos/asf/solr.git
commit 45cbb3ae55c5541891b69825f3a454d9adf22380
Author: Mikhail Khludnev <mk...@apache.org>
AuthorDate: Wed Oct 7 18:04:44 2026 +0300
SOLR-18508: {!auxIndexJoin} prune join-index column via `[to-min..to-max]` range (#5033)
(cherry picked from commit 2f9c868c24aa3cd60e34df1c103e89d485fcf9f5)
(cherry picked from commit 2e61cd70d8e6b1fcec8c19f79c904240800e2f38)
---
...8508-auxIndexJoin-skip-out-of-range-columns.yml | 11 +++
.../join/auxindexjoin/JoinIndexScorerSupplier.java | 92 ++++++++++++++++------
2 files changed, 81 insertions(+), 22 deletions(-)
diff --git a/changelog/unreleased/SOLR-18508-auxIndexJoin-skip-out-of-range-columns.yml b/changelog/unreleased/SOLR-18508-auxIndexJoin-skip-out-of-range-columns.yml
new file mode 100644
index 00000000000..78e7acf62c2
--- /dev/null
+++ b/changelog/unreleased/SOLR-18508-auxIndexJoin-skip-out-of-range-columns.yml
@@ -0,0 +1,11 @@
+title: >
+ Faster {!auxIndexJoin} confirmation: join columns whose to-doc range doesn't cover the candidate doc are skipped or dropped without being read.
+
+ Diagnostic logging now reports empty and skipped columns.
+type: changed
+authors:
+ - name: Mikhail Khludnev
+ nick: mkhl
+links:
+ - name: SOLR-18508
+ url: https://issues.apache.org/jira/browse/SOLR-18508
diff --git a/solr/core/src/java/org/apache/solr/search/join/auxindexjoin/JoinIndexScorerSupplier.java b/solr/core/src/java/org/apache/solr/search/join/auxindexjoin/JoinIndexScorerSupplier.java
index 9fa09423676..d55bc3710d7 100644
--- a/solr/core/src/java/org/apache/solr/search/join/auxindexjoin/JoinIndexScorerSupplier.java
+++ b/solr/core/src/java/org/apache/solr/search/join/auxindexjoin/JoinIndexScorerSupplier.java
@@ -75,9 +75,11 @@ import org.slf4j.LoggerFactory;
* lazy one never fires, so a log with no {@code cause=lazy-to-segment} line is the expected
* shape.
* <li>{@code evt=ctx} -- this context finished setting up: how many (from, to) pairs contributed,
- * how many the a-priori from-edge check dropped before any column was opened, and how loose
- * the resulting approximation is. Emitted from {@link #get}, with {@code mode=eager} when
- * every column is drained up front instead of confirmed lazily.
+ * how many the a-priori from-edge check dropped before any column was opened ({@code
+ * cellsEmpty} of them because the pair maps no from doc at all, the rest because the query's
+ * from matches miss the pair's from-range), and how loose the resulting approximation is.
+ * Emitted from {@link #get}, with {@code mode=eager} when every column is drained up front
+ * instead of confirmed lazily.
* <li>{@code evt=drain} -- one join column was read through during confirmation, and whether that
* read confirmed the doc under test (an early exit) or not.
* <li>{@code evt=done} -- confirmation reached a terminal state for this context: every column
@@ -139,6 +141,12 @@ class JoinIndexScorerSupplier extends ScorerSupplier {
/** pairs the a-priori from-edge check dropped, i.e. columns never opened at all */
private int leafsDroppedApriori;
+ /**
+ * those of {@link #leafsDroppedApriori} whose pair maps no from doc to this to segment at all: a
+ * property of the index layout, not of the query
+ */
+ private int leafsEmpty;
+
/** calls to {@link LazyConfirmationIterator#matches()} */
private int confirmCalls;
@@ -148,6 +156,11 @@ class JoinIndexScorerSupplier extends ScorerSupplier {
/** columns read through during confirmation */
private int leafsDrained;
+ /**
+ * columns dropped unread during confirmation, because the doc under test passed their to-range
+ */
+ private int leafsPassed;
+
/** from-docs walked while draining, i.e. the column reads laziness is trying to avoid */
private long fromDocsWalked;
@@ -199,6 +212,26 @@ class JoinIndexScorerSupplier extends ScorerSupplier {
} // otherwise we don't know if 0 is real false
}
+ // only cells whose to-range covers the doc can confirm it. One ending below it can't map it
+ // or any later doc, since the approximation only moves forward, so it's dropped unread. One
+ // starting above it stays for the docs to come.
+ final int doc = approximation.docID();
+ List<LeafJoin> covering = new ArrayList<>(leafJoins.size());
+ for (LeafJoin joinTask : new ArrayList<>(leafJoins)) {
+ if (doc > joinTask.toDocEdges()[1]) {
+ JoinIndexScorerSupplier.this.dropJoinLeaf(joinTask);
+ leafsPassed++;
+ } else if (doc >= joinTask.toDocEdges()[0]) {
+ covering.add(joinTask);
+ }
+ }
+ if (covering.isEmpty()) {
+ if (leafJoins.isEmpty()) {
+ converge(doc);
+ }
+ return false;
+ }
+
IndexSearcher freshSearcher = JoinIndexScorerSupplier.this.joinIndex.acquire();
try {
// the result matters here too: a cell whose column the reaper dropped is rebuilt by the
@@ -208,13 +241,12 @@ class JoinIndexScorerSupplier extends ScorerSupplier {
entry.getKey().bind(entry.getValue());
}
assert Objects.equals(JoinIndexScorerSupplier.this.lastSeenJoinSearcher, freshSearcher);
- for (LeafJoin joinTask : new ArrayList<>(leafJoins)) {
- if (falseNegToDocsBits == null) {
- this.shift = approximation.docID();
- falseNegToDocsBits = new FixedBitSet(lastToDoc + 1 - shift);
- }
- DrainOutcome outcome =
- joinTask.dumpMatchesInto(falseNegToDocsBits, shift, approximation.docID());
+ if (falseNegToDocsBits == null) {
+ this.shift = doc;
+ falseNegToDocsBits = new FixedBitSet(lastToDoc + 1 - shift);
+ }
+ for (LeafJoin joinTask : covering) {
+ DrainOutcome outcome = joinTask.dumpMatchesInto(falseNegToDocsBits, shift, doc);
fromDocsWalked += joinTask.lastDrainWalked();
if (outcome == DrainOutcome.CONFIRMED) {
logDrain(joinTask, true, falseNegToDocsBits);
@@ -231,17 +263,30 @@ class JoinIndexScorerSupplier extends ScorerSupplier {
} finally {
JoinIndexScorerSupplier.this.joinIndex.release(freshSearcher);
}
- // drop all to masks, got no hit - it means it's a true negative now.
-
- falsePositiveToDocsBits.clear(shift, lastToDoc + 1);
- FixedBitSet.orRange(
- falseNegToDocsBits, 0, falsePositiveToDocsBits, shift, lastToDoc - shift + 1);
+ // every covering cell was drained without a hit, so the doc is a true negative; cells
+ // starting above it may remain, and until they are gone the union is still half-read
+ if (leafJoins.isEmpty()) {
+ converge(doc);
+ }
+ return false;
+ }
- boolean matched = falsePositiveToDocsBits.get(approximation.docID());
- // every column has now been drained: the half-read union has converged, so from here on
- // every answer -- true or false -- is a free lookup and there is nothing left to prune
- logConfirmationDone(matched ? "converged-on-match" : "converged-on-refutation");
- return matched;
+ /**
+ * Narrows the approximation to the drained union once no cell is left, so from here on every
+ * answer -- true or false -- is a free lookup and there is nothing left to prune. Docs below
+ * {@code doc} are behind the iterator and left as they are.
+ */
+ private void converge(int doc) {
+ if (falseNegToDocsBits == null) {
+ // nothing was ever drained: every cell was passed unread, so nothing ahead can match
+ falsePositiveToDocsBits.clear(doc, lastToDoc + 1);
+ } else {
+ falsePositiveToDocsBits.clear(shift, lastToDoc + 1);
+ FixedBitSet.orRange(
+ falseNegToDocsBits, 0, falsePositiveToDocsBits, shift, lastToDoc - shift + 1);
+ }
+ assert !falsePositiveToDocsBits.get(doc);
+ logConfirmationDone("converged");
}
@Override
@@ -719,7 +764,7 @@ class JoinIndexScorerSupplier extends ScorerSupplier {
JoinIndexUtils.logDiagnostic(
log,
"AUXIJOIN evt=ctx ctx={} toSeg={} mode={} toMaxDoc={} cellsCreated={}"
- + " cellsDroppedApriori={} cellsLive={} buildMs={} approxCard={} approxSpanSum={} approxFrom={} approxTo={}"
+ + " cellsDroppedApriori={} cellsEmpty={} cellsLive={} buildMs={} approxCard={} approxSpanSum={} approxFrom={} approxTo={}"
+ " colToCountSum={}",
ctxId,
JoinIndexUtils.segmentName(toContext),
@@ -727,6 +772,7 @@ class JoinIndexScorerSupplier extends ScorerSupplier {
toContext.reader().maxDoc(),
joinLeafsCreated,
leafsDroppedApriori,
+ leafsEmpty,
leafJoins.size(),
joinIndexBuildNanos / 1_000_000L,
falsePositiveToDocsBits == null ? 0 : falsePositiveToDocsBits.cardinality(),
@@ -749,7 +795,7 @@ class JoinIndexScorerSupplier extends ScorerSupplier {
JoinIndexUtils.logDiagnostic(
log,
"AUXIJOIN evt=done ctx={} toSeg={} reason={} confirmCalls={} freeHits={} cellsDrained={}"
- + " cellsLive={} fromDocsWalked={} rebindsAfterReap={} fkLateLoads={} modelsReleased={}"
+ + " cellsPassed={} cellsLive={} fromDocsWalked={} rebindsAfterReap={} fkLateLoads={} modelsReleased={}"
+ " buildMs={}",
ctxId,
JoinIndexUtils.segmentName(toContext),
@@ -757,6 +803,7 @@ class JoinIndexScorerSupplier extends ScorerSupplier {
confirmCalls,
confirmFreeHits,
leafsDrained,
+ leafsPassed,
leafJoins.size(),
fromDocsWalked,
rebindsAfterReap,
@@ -988,6 +1035,7 @@ class JoinIndexScorerSupplier extends ScorerSupplier {
if (minFromDoc < 0) {
// {-1, -1} sentinel: this pair maps no from doc to any to doc at all
leafsDroppedApriori++;
+ leafsEmpty++;
dropJoinLeaf(cell);
return false;
}
(solr) 02/10: SOLR-13202: Return 400 instead of 500 for join queries missing from/to parameters (#5012)
Posted by ab...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch branch_10_1
in repository https://gitbox.apache.org/repos/asf/solr.git
commit 16c89f928e22c90f18c66edfc5ac8675d600f0e0
Author: Nick <ni...@gmail.com>
AuthorDate: Wed Oct 7 09:03:48 2026 -0600
SOLR-13202: Return 400 instead of 500 for join queries missing from/to parameters (#5012)
(cherry picked from commit 93e357bcf6bc9b3b6195043529ef5e1fa2001fde)
(cherry picked from commit a9d489d2035d6ee920f2068f025c6217a934603a)
---
changelog/unreleased/SOLR-13202.yml | 7 +++++++
.../org/apache/solr/search/JoinQParserPlugin.java | 2 ++
.../search/join/AuxIndexJoinQParserPlugin.java | 4 +---
.../search/join/CrossCollectionJoinQParser.java | 1 +
.../solr/search/join/ScoreJoinQParserPlugin.java | 13 ++++++++++++
solr/core/src/test/org/apache/solr/TestJoin.java | 15 ++++++++++++++
.../search/join/CrossCollectionJoinQueryTest.java | 23 ++++++++++++++++++++++
.../search/join/TestAuxIndexJoinQParserPlugin.java | 11 +++++++----
.../search/join/TestGlobalOrdinalsJoinQParser.java | 13 ++++++++++++
9 files changed, 82 insertions(+), 7 deletions(-)
diff --git a/changelog/unreleased/SOLR-13202.yml b/changelog/unreleased/SOLR-13202.yml
new file mode 100644
index 00000000000..1d4ea052cec
--- /dev/null
+++ b/changelog/unreleased/SOLR-13202.yml
@@ -0,0 +1,7 @@
+title: Return 400 instead of 500 for join queries, including cross-collection joins, that are missing the from or to parameter
+type: fixed
+authors:
+ - name: Nick Shanin
+links:
+ - name: SOLR-13202
+ url: https://issues.apache.org/jira/browse/SOLR-13202
diff --git a/solr/core/src/java/org/apache/solr/search/JoinQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/JoinQParserPlugin.java
index b403c0c92a2..343210cde7f 100644
--- a/solr/core/src/java/org/apache/solr/search/JoinQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/JoinQParserPlugin.java
@@ -146,6 +146,8 @@ public class JoinQParserPlugin extends QParserPlugin {
final String v = qparser.localParams.get(QueryParsing.V);
final String coreName;
+ ScoreJoinQParserPlugin.requireFromAndTo(fromField, toField);
+
Query fromQuery;
long fromCoreOpenTime = 0;
diff --git a/solr/core/src/java/org/apache/solr/search/join/AuxIndexJoinQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/join/AuxIndexJoinQParserPlugin.java
index 9535dcf5226..0f7cfee6317 100644
--- a/solr/core/src/java/org/apache/solr/search/join/AuxIndexJoinQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/join/AuxIndexJoinQParserPlugin.java
@@ -408,9 +408,7 @@ public class AuxIndexJoinQParserPlugin extends QParserPlugin
}
final String fromField = getParam("from");
final String toField = getParam("to");
- if (fromField == null || toField == null) {
- throw new SyntaxError("auxIndexJoin query parser requires 'from' and 'to' local params");
- }
+ ScoreJoinQParserPlugin.requireFromAndTo(fromField, toField);
final String fromIndex = localParams.get("fromIndex");
final String v = localParams.get(CommonParams.VALUE);
final String myCore = req.getCore().getCoreDescriptor().getName();
diff --git a/solr/core/src/java/org/apache/solr/search/join/CrossCollectionJoinQParser.java b/solr/core/src/java/org/apache/solr/search/join/CrossCollectionJoinQParser.java
index 28b08154f57..4581facf15d 100644
--- a/solr/core/src/java/org/apache/solr/search/join/CrossCollectionJoinQParser.java
+++ b/solr/core/src/java/org/apache/solr/search/join/CrossCollectionJoinQParser.java
@@ -106,6 +106,7 @@ public class CrossCollectionJoinQParser extends QParser {
String collection = localParams.get(FROM_INDEX);
String fromField = localParams.get(FROM);
String toField = localParams.get(TO);
+ ScoreJoinQParserPlugin.requireFromAndTo(fromField, toField);
boolean routedByJoinKey = localParams.getBool(ROUTED_BY_JOIN_KEY, toField.equals(routerField));
int ttl = localParams.getInt(TTL, TTL_DEFAULT);
diff --git a/solr/core/src/java/org/apache/solr/search/join/ScoreJoinQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/join/ScoreJoinQParserPlugin.java
index 29b4a44f432..08beafdc190 100644
--- a/solr/core/src/java/org/apache/solr/search/join/ScoreJoinQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/join/ScoreJoinQParserPlugin.java
@@ -355,6 +355,18 @@ public class ScoreJoinQParserPlugin extends QParserPlugin {
}
}
+ /** Fails with a bad request if a join has no {@code from} or no {@code to} field. */
+ public static void requireFromAndTo(String fromField, String toField) {
+ if (fromField == null) {
+ throw new SolrException(
+ SolrException.ErrorCode.BAD_REQUEST, "Join query missing required 'from' parameter");
+ }
+ if (toField == null) {
+ throw new SolrException(
+ SolrException.ErrorCode.BAD_REQUEST, "Join query missing required 'to' parameter");
+ }
+ }
+
@Override
public QParser createParser(
String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) {
@@ -364,6 +376,7 @@ public class ScoreJoinQParserPlugin extends QParserPlugin {
final String fromField = localParams.get("from");
final String fromIndex = localParams.get("fromIndex");
final String toField = localParams.get("to");
+ requireFromAndTo(fromField, toField);
final ScoreMode scoreMode = ScoreModeParser.parse(getParam(SCORE));
final String v = localParams.get(CommonParams.VALUE);
diff --git a/solr/core/src/test/org/apache/solr/TestJoin.java b/solr/core/src/test/org/apache/solr/TestJoin.java
index 14f776610ba..85e4b4f128b 100644
--- a/solr/core/src/test/org/apache/solr/TestJoin.java
+++ b/solr/core/src/test/org/apache/solr/TestJoin.java
@@ -490,4 +490,19 @@ public class TestJoin extends SolrTestCaseJ4 {
return "{!join " + allProvidedParams + " method=topLevelDV}";
}
}
+
+ @Test
+ public void testJoinMissingFromToReturns400() {
+ for (String method :
+ List.of("", "method=dvWithScore score=none", "method=topLevelDV", "score=none")) {
+ assertMissingJoinParam("{!join to=id " + method + "}*:*", "from");
+ assertMissingJoinParam("{!join from=id " + method + "}*:*", "to");
+ }
+ }
+
+ private void assertMissingJoinParam(String query, String missing) {
+ SolrException e = expectThrows(SolrException.class, () -> h.query(req("q", query, "fl", "id")));
+ assertEquals(query, SolrException.ErrorCode.BAD_REQUEST.code, e.code());
+ assertTrue(e.getMessage(), e.getMessage().contains("'" + missing + "'"));
+ }
}
diff --git a/solr/core/src/test/org/apache/solr/search/join/CrossCollectionJoinQueryTest.java b/solr/core/src/test/org/apache/solr/search/join/CrossCollectionJoinQueryTest.java
index 341be4d6223..2b6e50693fd 100644
--- a/solr/core/src/test/org/apache/solr/search/join/CrossCollectionJoinQueryTest.java
+++ b/solr/core/src/test/org/apache/solr/search/join/CrossCollectionJoinQueryTest.java
@@ -30,6 +30,7 @@ import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.cloud.SolrCloudTestCase;
+import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.cloud.DocCollection;
import org.apache.solr.common.cloud.Replica;
@@ -469,6 +470,28 @@ public class CrossCollectionJoinQueryTest extends SolrCloudTestCase {
}
}
+ @Test
+ public void testMissingFromOrToAtParser() throws Exception {
+ for (String missing : List.of(CrossCollectionJoinQParser.FROM, CrossCollectionJoinQParser.TO)) {
+ ModifiableSolrParams localParams = new ModifiableSolrParams();
+ localParams.set(QueryParsing.V, "*:*");
+ localParams.set(CrossCollectionJoinQParser.FROM_INDEX, "products");
+ localParams.set(CrossCollectionJoinQParser.FROM, "product_id_s");
+ localParams.set(CrossCollectionJoinQParser.TO, "product_id_s");
+ localParams.remove(missing);
+
+ ModifiableSolrParams requestParams = new ModifiableSolrParams();
+ try (SolrQueryRequest req = new SolrQueryRequestBase(null, requestParams) {}) {
+ CrossCollectionJoinQParser parser =
+ new CrossCollectionJoinQParser(
+ null, localParams, requestParams, req, "product_id_s", null);
+ SolrException e = expectThrows(SolrException.class, parser::parse);
+ assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, e.code());
+ assertTrue(e.getMessage(), e.getMessage().contains("'" + missing + "'"));
+ }
+ }
+ }
+
@Test
public void testShardsPreferenceRequestParamPropagation() throws Exception {
// shards.preference set as a request-level param (not in localParams) should be
diff --git a/solr/core/src/test/org/apache/solr/search/join/TestAuxIndexJoinQParserPlugin.java b/solr/core/src/test/org/apache/solr/search/join/TestAuxIndexJoinQParserPlugin.java
index 4c1871f8d36..9685ed74bac 100644
--- a/solr/core/src/test/org/apache/solr/search/join/TestAuxIndexJoinQParserPlugin.java
+++ b/solr/core/src/test/org/apache/solr/search/join/TestAuxIndexJoinQParserPlugin.java
@@ -119,12 +119,15 @@ public class TestAuxIndexJoinQParserPlugin extends SolrTestCase {
@Test
public void testMissingLocalParams() {
+ assertMissingJoinParam("{!auxIndexJoin to=dept_id_s}*:*", "from");
+ assertMissingJoinParam("{!auxIndexJoin from=dept_s}*:*", "to");
+ }
+
+ private void assertMissingJoinParam(String query, String missing) {
SolrException e =
- expectThrows(
- SolrException.class,
- () -> solrRule.getSolrClient().query(params("q", "{!auxIndexJoin to=dept_id_s}*:*")));
+ expectThrows(SolrException.class, () -> solrRule.getSolrClient().query(params("q", query)));
assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, e.code());
- assertTrue(e.getMessage(), e.getMessage().contains("requires"));
+ assertTrue(e.getMessage(), e.getMessage().contains("missing required '" + missing + "'"));
}
@Test
diff --git a/solr/core/src/test/org/apache/solr/search/join/TestGlobalOrdinalsJoinQParser.java b/solr/core/src/test/org/apache/solr/search/join/TestGlobalOrdinalsJoinQParser.java
index 7cd72a52516..04eebca7f54 100644
--- a/solr/core/src/test/org/apache/solr/search/join/TestGlobalOrdinalsJoinQParser.java
+++ b/solr/core/src/test/org/apache/solr/search/join/TestGlobalOrdinalsJoinQParser.java
@@ -442,6 +442,19 @@ public class TestGlobalOrdinalsJoinQParser extends SolrTestCaseJ4 {
assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, ex.code());
assertTrue(ex.getMessage().contains("which"));
+ // Missing from query (no query body and no 'v' local param)
+ ex =
+ expectThrows(
+ SolrException.class,
+ () -> {
+ h.query(
+ req(
+ "q",
+ "{!globalOrdinalsJoin joinField=join_s_dv which=\\\"type_s:parent\\\"}"));
+ });
+ assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, ex.code());
+ assertTrue(ex.getMessage().contains("from query is required"));
+
// Invalid score mode
ex =
expectThrows(
(solr) 05/10: SOLR-18504: Merge duplicate OpenAPI path templates (#5024)
Posted by ab...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch branch_10_1
in repository https://gitbox.apache.org/repos/asf/solr.git
commit cffb9012cdaf0c157283c82c29a550e50a0b7741
Author: Jan Høydahl <ja...@apache.org>
AuthorDate: Wed Oct 7 14:39:27 2026 +0200
SOLR-18504: Merge duplicate OpenAPI path templates (#5024)
(cherry picked from commit a2f43aadfd212f6d9f05cdcdb5bd27b11fac81b1)
(cherry picked from commit b5f148ad7bb4547b4257053cb8035c621413bf50)
---
.../SOLR-18504-duplicate-path-templates.yml | 10 +++++++++
solr/api/build.gradle | 24 ++++++++++++++++++++++
.../client/api/endpoint/ClusterFileStoreApis.java | 4 ++--
.../solr/client/api/endpoint/GetSchemaApi.java | 5 +++--
.../solr/handler/admin/api/GetSchemaField.java | 10 ++++-----
5 files changed, 44 insertions(+), 9 deletions(-)
diff --git a/changelog/unreleased/SOLR-18504-duplicate-path-templates.yml b/changelog/unreleased/SOLR-18504-duplicate-path-templates.yml
new file mode 100644
index 00000000000..1e93ea2bcd9
--- /dev/null
+++ b/changelog/unreleased/SOLR-18504-duplicate-path-templates.yml
@@ -0,0 +1,10 @@
+title: >
+ The OpenAPI spec no longer describes the same URL twice: the dynamic-field and filestore-file
+ endpoints each named their path parameter differently per HTTP method, so consumers of the spec
+ saw two colliding entries, each missing the other's operations.
+type: fixed
+authors:
+ - name: Jan Høydahl
+links:
+ - name: SOLR-18504
+ url: https://issues.apache.org/jira/browse/SOLR-18504
diff --git a/solr/api/build.gradle b/solr/api/build.gradle
index fb42df27a30..58386b103f2 100644
--- a/solr/api/build.gradle
+++ b/solr/api/build.gradle
@@ -79,6 +79,30 @@ dependencies {
swaggerBuild libs.swagger3.jaxrs2.jakarta
}
+// OpenAPI treats templated paths that differ only in parameter name as the same path, so
+// such a collision silently hides operations from consumers of the spec.
+tasks.register('validateOpenApiSpec') {
+ dependsOn resolve
+ def specFile = file(project.openApiSpecFile)
+ def marker = layout.buildDirectory.file("openapi-spec-validated.txt").get().asFile
+ inputs.file(specFile)
+ outputs.file(marker)
+ doLast {
+ def collisions = new groovy.json.JsonSlurper().parse(specFile).paths.keySet()
+ .groupBy { it.replaceAll(/\{[^}]*\}/, '{}') }
+ .findAll { it.value.size() > 1 }
+ if (!collisions.isEmpty()) {
+ throw new GradleException(
+ "OpenAPI spec declares paths that differ only in path-parameter name:\n"
+ + collisions.values().flatten().collect { " " + it }.join("\n") + "\n"
+ + "Make the @PathParam names agree so the operations merge into a single path.")
+ }
+ marker.text = "ok"
+ }
+}
+
+check.dependsOn validateOpenApiSpec
+
// Non-Java client generation tasks below:
task buildJSClient(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) {
generatorName.set("javascript")
diff --git a/solr/api/src/java/org/apache/solr/client/api/endpoint/ClusterFileStoreApis.java b/solr/api/src/java/org/apache/solr/client/api/endpoint/ClusterFileStoreApis.java
index e8dafdd4498..9effa63f791 100644
--- a/solr/api/src/java/org/apache/solr/client/api/endpoint/ClusterFileStoreApis.java
+++ b/solr/api/src/java/org/apache/solr/client/api/endpoint/ClusterFileStoreApis.java
@@ -87,10 +87,10 @@ public interface ClusterFileStoreApis {
@Operation(
summary = "Delete a file or directory from the filestore.",
tags = {"file-store"})
- @Path("/files{path:.+}")
+ @Path("/files{filePath:.+}")
SolrJerseyResponse deleteFile(
@Parameter(description = "Path to a file or directory within the filestore")
- @PathParam("path")
+ @PathParam("filePath")
String path,
@Parameter(
description =
diff --git a/solr/api/src/java/org/apache/solr/client/api/endpoint/GetSchemaApi.java b/solr/api/src/java/org/apache/solr/client/api/endpoint/GetSchemaApi.java
index 119bf9d19ce..a42f832b154 100644
--- a/solr/api/src/java/org/apache/solr/client/api/endpoint/GetSchemaApi.java
+++ b/solr/api/src/java/org/apache/solr/client/api/endpoint/GetSchemaApi.java
@@ -78,12 +78,13 @@ public interface GetSchemaApi {
SchemaListDynamicFieldsResponse listDynamicFields();
@GET
- @Path("/dynamicfields/{fieldName}")
+ @Path("/dynamicfields/{dynamicFieldName}")
@StoreApiParameters
@Operation(
summary = "Get detailed info about a single dynamic field",
tags = {"schema"})
- SchemaGetDynamicFieldInfoResponse getDynamicFieldInfo(@PathParam("fieldName") String fieldName);
+ SchemaGetDynamicFieldInfoResponse getDynamicFieldInfo(
+ @PathParam("dynamicFieldName") String dynamicFieldName);
@GET
@Path("/fieldtypes")
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/api/GetSchemaField.java b/solr/core/src/java/org/apache/solr/handler/admin/api/GetSchemaField.java
index 70fc868bee5..e19b08fc325 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/api/GetSchemaField.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/api/GetSchemaField.java
@@ -49,7 +49,7 @@ import org.apache.solr.security.PermissionNameProvider;
* <li>/fields/{fieldName}
* <li>/copyfields
* <li>/dynamicfields
- * <li>/dynamicfields/{fieldName}
+ * <li>/dynamicfields/{dynamicFieldName}
* <li>/fieldtypes
* <li>/fieldtypes/{fieldTypeName}
* </ul>
@@ -122,8 +122,8 @@ public class GetSchemaField extends JerseyResource implements GetSchemaApi.Field
@Override
@PermissionName(PermissionNameProvider.Name.SCHEMA_READ_PERM)
- public SchemaGetDynamicFieldInfoResponse getDynamicFieldInfo(String fieldName) {
- if (fieldName == null) {
+ public SchemaGetDynamicFieldInfoResponse getDynamicFieldInfo(String dynamicFieldName) {
+ if (dynamicFieldName == null) {
throw new SolrException(
SolrException.ErrorCode.BAD_REQUEST, "Dynamic field name must not be null");
}
@@ -132,13 +132,13 @@ public class GetSchemaField extends JerseyResource implements GetSchemaApi.Field
final String realName = "dynamicfields";
SimpleOrderedMap<Object> dynamicFieldInfo =
- retrieveFieldInfoOfType(realName, fieldName, params);
+ retrieveFieldInfoOfType(realName, dynamicFieldName, params);
if (dynamicFieldInfo != null) {
response.dynamicFieldInfo = dynamicFieldInfo;
return response;
}
throw new SolrException(
- SolrException.ErrorCode.NOT_FOUND, "No such dynamic field [" + fieldName + "]");
+ SolrException.ErrorCode.NOT_FOUND, "No such dynamic field [" + dynamicFieldName + "]");
}
@Override
(solr) 06/10: Test fix: TestCollapseQParserPlugin
Posted by ab...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch branch_10_1
in repository https://gitbox.apache.org/repos/asf/solr.git
commit a61ac63ab0a6559c729d867aa34568768b4059c1
Author: David Smiley <ds...@apache.org>
AuthorDate: Wed Oct 7 15:32:17 2026 -0400
Test fix: TestCollapseQParserPlugin
Flaky due to docid re-order.
(cherry picked from commit f0ec950113bce6430d3c08032697e6dde20701df)
(cherry picked from commit 9cace892d092410b7ffa3cda7fd0bdb9f2babe50)
---
.../src/test/org/apache/solr/search/TestCollapseQParserPlugin.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java b/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
index d8284e1fd1d..a8166da7782 100644
--- a/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
+++ b/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
@@ -32,6 +32,7 @@ import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.index.LogDocMergePolicyFactory;
import org.apache.solr.search.CollapsingQParserPlugin.GroupHeadSelector;
import org.apache.solr.search.CollapsingQParserPlugin.GroupHeadSelectorType;
import org.junit.Before;
@@ -44,6 +45,8 @@ public class TestCollapseQParserPlugin extends SolrTestCaseJ4 {
// we need DVs on point fields to compute stats & facets
if (Boolean.getBoolean(NUMERIC_POINTS_SYSPROP))
System.setProperty(NUMERIC_DOCVALUES_SYSPROP, "true");
+ // tie-breaking on group head depends on docid order; avoid merges that reorder docs
+ systemSetPropertySolrTestsMergePolicyFactory(LogDocMergePolicyFactory.class.getName());
initCore("solrconfig-collapseqparser.xml", "schema11.xml");
}
(solr) 08/10: SOLR-18124: Trace RecoveryStrategy with a span and events (#4961)
Posted by ab...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch branch_10_1
in repository https://gitbox.apache.org/repos/asf/solr.git
commit 295bd6c57efde8fc140d22092e0dbbc905c5ee02
Author: David Smiley <ds...@apache.org>
AuthorDate: Wed Oct 7 17:59:34 2026 -0400
SOLR-18124: Trace RecoveryStrategy with a span and events (#4961)
Co-authored-by: Claude Opus 5.5 <no...@anthropic.com>
(cherry picked from commit 709d65ec2f72ea393e30a3bc38c69ef51c0b2b36)
(cherry picked from commit 5087d328a6a62e05089d814344187d770649ca3a)
---
.../org/apache/solr/cloud/RecoveryStrategy.java | 54 +++++++++++++++++++++-
1 file changed, 53 insertions(+), 1 deletion(-)
diff --git a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
index 64b288ab6ad..38a0d8a0d1e 100644
--- a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
+++ b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
@@ -16,6 +16,9 @@
*/
package org.apache.solr.cloud;
+import io.opentelemetry.api.common.AttributeKey;
+import io.opentelemetry.api.common.Attributes;
+import io.opentelemetry.api.trace.Span;
import java.io.Closeable;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
@@ -68,6 +71,7 @@ import org.apache.solr.util.RTimer;
import org.apache.solr.util.RefCounted;
import org.apache.solr.util.SolrPluginUtils;
import org.apache.solr.util.plugin.NamedListInitializedPlugin;
+import org.apache.solr.util.tracing.TraceUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -103,6 +107,10 @@ public class RecoveryStrategy implements Runnable, Closeable {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final AttributeKey<String> LEADER_ATTR = AttributeKey.stringKey("leader");
+ private static final AttributeKey<Long> RETRY_ATTR = AttributeKey.longKey("retry");
+ private static final AttributeKey<Boolean> SUCCESS_ATTR = AttributeKey.booleanKey("success");
+
private int waitForUpdatesWithStaleStatePauseMilliSeconds =
Integer.getInteger("solr.cloud.wait-for-updates-with-stale-state-pause", 2500);
private int maxRetries = 500;
@@ -131,6 +139,9 @@ public class RecoveryStrategy implements Runnable, Closeable {
private CoreDescriptor coreDescriptor;
+ /** Recorded on the trace span; null until recovery reaches a terminal state. */
+ private String outcome;
+
protected RecoveryStrategy(
CoreContainer cc, CoreDescriptor cd, RecoveryListener recoveryListener) {
this.cc = cc;
@@ -205,6 +216,7 @@ public class RecoveryStrategy implements Runnable, Closeable {
private final void recoveryFailed(final ZkController zkController, final CoreDescriptor cd)
throws Exception {
log.error("Recovery failed - I give up.");
+ setOutcome("failed");
try {
zkController.publish(cd, Replica.State.RECOVERY_FAILED);
} finally {
@@ -230,6 +242,7 @@ public class RecoveryStrategy implements Runnable, Closeable {
final String leaderCore = URLUtil.extractCoreFromCoreUrl(getReplicateLeaderUrl(leaderprops));
log.info("Attempting to replicate from core [{}] on node [{}].", leaderCore, leaderBaseUrl);
+ Span.current().addEvent("replicate");
// send commit if replica could be a leader
if (replicaType.leaderEligible) {
@@ -323,15 +336,33 @@ public class RecoveryStrategy implements Runnable, Closeable {
log.info("Starting recovery process. recoveringAfterStartup={}", recoveringAfterStartup);
final RTimer timer = new RTimer();
- try {
+ final Span span =
+ TraceUtils.getGlobalTracer()
+ .spanBuilder("recovery")
+ .setAttribute(TraceUtils.TAG_DB, coreName)
+ .setAttribute("recovery.afterStartup", recoveringAfterStartup)
+ .startSpan();
+ try (var scope = span.makeCurrent()) {
+ assert scope != null; // prevent javac warning about scope being unused
doRecovery(core);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
log.error("interrupted", e);
+ span.recordException(e);
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e);
} catch (Exception e) {
log.error("", e);
+ span.recordException(e);
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR, "", e);
+ } finally {
+ if (outcome == null && isClosed()) {
+ outcome = "closed";
+ }
+ if (outcome != null) {
+ span.setAttribute("recovery.outcome", outcome);
+ }
+ span.setAttribute("recovery.retries", retries);
+ span.end();
}
if (log.isInfoEnabled()) {
@@ -348,8 +379,10 @@ public class RecoveryStrategy implements Runnable, Closeable {
this.coreDescriptor = core.getCoreDescriptor();
if (this.coreDescriptor.getCloudDescriptor().getReplicaType().requireTransactionLog) {
+ Span.current().setAttribute("recovery.strategy", "syncOrReplicate");
doSyncOrReplicateRecovery(core);
} else {
+ Span.current().setAttribute("recovery.strategy", "replicateOnly");
doReplicateOnlyRecovery(core);
}
}
@@ -373,6 +406,7 @@ public class RecoveryStrategy implements Runnable, Closeable {
zkStateReader.getLeaderRetry(cloudDesc.getCollectionName(), cloudDesc.getShardId());
final String leaderUrl = leader.getCoreUrl();
final String ourUrl = ZkCoreNodeProps.getCoreUrl(baseUrl, coreName);
+ Span.current().addEvent("leaderFound", Attributes.of(LEADER_ATTR, leaderUrl));
// TODO: We can probably delete most of this code if we say this strategy can only be used
// for pull replicas
@@ -385,6 +419,7 @@ public class RecoveryStrategy implements Runnable, Closeable {
// we are now the leader - no one else must have been suitable
log.warn("We have not yet recovered - but we are now the leader!");
log.info("Finished recovery process.");
+ setOutcome("becameLeader");
zkController.publish(this.coreDescriptor, Replica.State.ACTIVE);
return;
}
@@ -435,6 +470,7 @@ public class RecoveryStrategy implements Runnable, Closeable {
zkController.startReplicationFromLeader(coreName, false);
}
log.info("Registering as Active after recovery.");
+ Span.current().addEvent("publishActive");
try {
zkController.publish(this.coreDescriptor, Replica.State.ACTIVE);
} catch (Exception e) {
@@ -443,6 +479,7 @@ public class RecoveryStrategy implements Runnable, Closeable {
}
if (successfulRecovery) {
+ setOutcome("recovered");
close = true;
recoveryListener.recovered();
}
@@ -476,6 +513,7 @@ public class RecoveryStrategy implements Runnable, Closeable {
}
log.error("Recovery failed - trying again... ({})", retries);
+ Span.current().addEvent("retry", Attributes.of(RETRY_ATTR, (long) retries));
retries++;
if (retries >= maxRetries) {
@@ -613,6 +651,7 @@ public class RecoveryStrategy implements Runnable, Closeable {
log.info("RecoveryStrategy has been closed");
break;
}
+ Span.current().addEvent("leaderFound", Attributes.of(LEADER_ATTR, leader.getCoreUrl()));
boolean isLeader = leader.getCoreUrl().equals(ourUrl);
if (isLeader && !cloudDesc.isLeader()) {
@@ -622,11 +661,13 @@ public class RecoveryStrategy implements Runnable, Closeable {
// we are now the leader - no one else must have been suitable
log.warn("We have not yet recovered - but we are now the leader!");
log.info("Finished recovery process.");
+ setOutcome("becameLeader");
zkController.publish(this.coreDescriptor, Replica.State.ACTIVE);
return;
}
log.info("Begin buffering updates. core=[{}]", coreName);
+ Span.current().addEvent("bufferUpdates");
// recalling buffer updates will drop the old buffer tlog
ulog.bufferUpdates();
@@ -683,11 +724,13 @@ public class RecoveryStrategy implements Runnable, Closeable {
}
// System.out.println("Attempting to PeerSync from " + leaderUrl
// + " i am:" + zkController.getNodeName());
+ Span.current().addEvent("peerSync");
boolean syncSuccess;
try (PeerSyncWithLeader peerSyncWithLeader =
new PeerSyncWithLeader(core, leader.getCoreUrl(), ulog.getNumRecordsToKeep())) {
syncSuccess = peerSyncWithLeader.sync(recentVersions).isSuccess();
}
+ Span.current().addEvent("peerSyncDone", Attributes.of(SUCCESS_ATTR, syncSuccess));
if (syncSuccess) {
SolrQueryRequest req = new SolrQueryRequestBase(core, new ModifiableSolrParams());
// force open a new searcher
@@ -747,6 +790,7 @@ public class RecoveryStrategy implements Runnable, Closeable {
} finally {
if (successfulRecovery) {
log.info("Registering as Active after recovery.");
+ Span.current().addEvent("publishActive");
try {
if (replicaType.replicateFromLeader) {
zkController.startReplicationFromLeader(coreName, true);
@@ -758,6 +802,7 @@ public class RecoveryStrategy implements Runnable, Closeable {
}
if (successfulRecovery) {
+ setOutcome("recovered");
close = true;
recoveryListener.recovered();
}
@@ -863,8 +908,10 @@ public class RecoveryStrategy implements Runnable, Closeable {
log.info("No replay needed.");
} else {
log.info("Replaying buffered documents.");
+ Span.current().addEvent("replay");
// wait for replay
RecoveryInfo report = future.get();
+ Span.current().addEvent("replayDone", Attributes.of(SUCCESS_ATTR, !report.failed));
if (report.failed) {
log.error("Replay failed");
throw new SolrException(ErrorCode.SERVER_ERROR, "Replay failed");
@@ -900,6 +947,11 @@ public class RecoveryStrategy implements Runnable, Closeable {
}
}
+ private void setOutcome(String outcome) {
+ this.outcome = outcome;
+ Span.current().addEvent(outcome);
+ }
+
public final boolean isClosed() {
return close || cc.isShutDown();
}
(solr) 04/10: SOLR-18124: Trace index replication with a span (#4963)
Posted by ab...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch branch_10_1
in repository https://gitbox.apache.org/repos/asf/solr.git
commit 96eadd9d24731455df025e5197bbb9f84f806732
Author: David Smiley <ds...@apache.org>
AuthorDate: Wed Oct 7 14:38:41 2026 -0400
SOLR-18124: Trace index replication with a span (#4963)
Co-authored-by: Claude Opus 5.5 <no...@anthropic.com>
(cherry picked from commit 6d6504668e3cac77f74d6ad2b2b20754de1c3bec)
(cherry picked from commit b20293b157365b096e96e91ec85e313fb67b5b59)
---
.../java/org/apache/solr/handler/IndexFetcher.java | 8 ++++++++
.../apache/solr/handler/ReplicationHandler.java | 24 +++++++++++++++++++++-
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
index b6fa1146959..2652f2add4c 100644
--- a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
+++ b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
@@ -37,6 +37,7 @@ import static org.apache.solr.handler.admin.api.ReplicationAPIBase.FILE_STREAM;
import static org.apache.solr.handler.admin.api.ReplicationAPIBase.GENERATION;
import static org.apache.solr.handler.admin.api.ReplicationAPIBase.OFFSET;
+import io.opentelemetry.api.trace.Span;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -499,6 +500,9 @@ public class IndexFetcher {
log.info("Leader's generation: {}", latestGeneration);
log.info("Leader's version: {}", latestVersion);
+ Span.current()
+ .setAttribute("replication.leader", leaderCoreUrl)
+ .setAttribute("replication.leaderGeneration", latestGeneration);
// TODO: make sure that getLatestCommit only returns commit points for the main index (i.e. no
// side-car indexes)
@@ -576,6 +580,7 @@ public class IndexFetcher {
if (log.isInfoEnabled()) {
log.info("Number of files in latest index in leader: {}", filesToDownload.size());
}
+ Span.current().setAttribute("replication.leaderFiles", filesToDownload.size());
// Create the sync service
fsyncService =
@@ -687,6 +692,9 @@ public class IndexFetcher {
timeTakenSeconds,
bytesDownloadedPerSecond,
tmpIndexDir);
+ Span.current()
+ .setAttribute("replication.fullCopy", isFullCopyNeeded)
+ .setAttribute("replication.bytesDownloaded", bytesDownloaded);
Collection<Map<String, Object>> modifiedConfFiles =
getModifiedConfFiles(confFilesToDownload);
diff --git a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
index ddd9793932b..6278a33fbfb 100644
--- a/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
@@ -33,6 +33,8 @@ import static org.apache.solr.handler.admin.api.ReplicationAPIBase.TLOG_FILE;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.metrics.ObservableDoubleMeasurement;
import io.opentelemetry.api.metrics.ObservableLongMeasurement;
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.StatusCode;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@@ -115,6 +117,7 @@ import org.apache.solr.util.NumberUtils;
import org.apache.solr.util.RefCounted;
import org.apache.solr.util.plugin.SolrCoreAware;
import org.apache.solr.util.stats.MetricUtils;
+import org.apache.solr.util.tracing.TraceUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
@@ -497,9 +500,28 @@ public class ReplicationHandler extends RequestHandlerBase
private volatile IndexFetcher currentIndexFetcher;
+ public IndexFetchResult doFetch(SolrParams solrParams, boolean forceReplication) {
+ final Span span = TraceUtils.getGlobalTracer().spanBuilder("replication").startSpan();
+ TraceUtils.setDbInstance(span, core.getName());
+ try (var scope = span.makeCurrent()) {
+ assert scope != null; // prevent javac warning about scope being unused
+ IndexFetchResult result = doFetchInternal(solrParams, forceReplication);
+ span.setAttribute("replication.result", result.getMessage());
+ if (!result.getSuccessful()) {
+ span.setStatus(StatusCode.ERROR);
+ }
+ if (result.getException() != null) {
+ span.recordException(result.getException());
+ }
+ return result;
+ } finally {
+ span.end();
+ }
+ }
+
@SuppressWarnings(
"ReferenceEquality") // detecting the shared pollingIndexFetcher vs. a one-off, by identity
- public IndexFetchResult doFetch(SolrParams solrParams, boolean forceReplication) {
+ private IndexFetchResult doFetchInternal(SolrParams solrParams, boolean forceReplication) {
String leaderUrl = solrParams.get(LEADER_URL, null);
if (!indexFetchLock.tryLock()) return IndexFetchResult.LOCK_OBTAIN_FAILED;
if (core.getCoreContainer().isShutDown()) {
(solr) 09/10: Fix incorrect v2 API examples in the Schema API ref guide (#4942)
Posted by ab...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch branch_10_1
in repository https://gitbox.apache.org/repos/asf/solr.git
commit f72a4a9c70590723c2c45295af282292d2aa6d6f
Author: Jan Høydahl <ja...@apache.org>
AuthorDate: Tue Oct 6 02:53:56 2026 +0200
Fix incorrect v2 API examples in the Schema API ref guide (#4942)
Co-authored-by: Eric Pugh <ep...@opensourceconnections.com>
(cherry picked from commit 97d973814336101e12475558d7419321c743de79)
(cherry picked from commit a0a0a26c5069da0bdda694a081880797f6ced448)
---
.../modules/indexing-guide/pages/schema-api.adoc | 82 ++++++++++++----------
1 file changed, 43 insertions(+), 39 deletions(-)
diff --git a/solr/solr-ref-guide/modules/indexing-guide/pages/schema-api.adoc b/solr/solr-ref-guide/modules/indexing-guide/pages/schema-api.adoc
index 9ce7813cdf6..e4ef15edc96 100644
--- a/solr/solr-ref-guide/modules/indexing-guide/pages/schema-api.adoc
+++ b/solr/solr-ref-guide/modules/indexing-guide/pages/schema-api.adoc
@@ -122,11 +122,11 @@ V2 API::
====
[source,bash]
----
-curl -X PUT -H 'Content-type:application/json' --data-binary '
+curl -X PUT 'http://localhost:8983/api/collections/techproducts/schema/fields/sell_by' -H 'Content-type:application/json' --data-binary '
{
"type":"pdate",
"stored":true
-}' http://localhost:8983/api/collections/techproducts/schema/fields/sell_by
+}'
----
====
======
@@ -156,7 +156,7 @@ V2 API::
====
[source,bash]
----
-curl -X DELETE "http://localhost:8983/api/collections/techproducts/schema/fields/sell_by"
+curl -X DELETE 'http://localhost:8983/api/collections/techproducts/schema/fields/sell_by'
----
====
======
@@ -193,10 +193,10 @@ V2 API::
====
[source,bash]
----
-curl -X PUT -H 'Content-type:application/json' --data-binary '{
+curl -X PUT 'http://localhost:8983/api/collections/techproducts/schema/fields/sell_by' -H 'Content-type:application/json' --data-binary '{
"type":"date",
"stored":false
-}' http://localhost:8983/api/collections/techproducts/schema/fields/sell_by
+}'
----
====
======
@@ -231,10 +231,10 @@ V2 API::
====
[source,bash]
----
-curl -X PUT -H 'Content-type:application/json' --data-binary '{
+curl -X PUT 'http://localhost:8983/api/collections/techproducts/schema/dynamicfields/*_s' -H 'Content-type:application/json' --data-binary '{
"type":"string",
"stored":true
-}' "http://localhost:8983/api/collections/techproducts/schema/dynamicfields/*_s"
+}'
----
====
======
@@ -264,7 +264,7 @@ V2 API::
====
[source,bash]
----
-curl -X DELETE "http://localhost:8983/api/collections/techproducts/schema/dynamicfields/*_s"
+curl -X DELETE 'http://localhost:8983/api/collections/techproducts/schema/dynamicfields/*_s'
----
====
======
@@ -301,10 +301,10 @@ V2 API::
====
[source,bash]
----
-curl -X PUT -H 'Content-type:application/json' --data-binary '{
+curl -X PUT 'http://localhost:8983/api/collections/techproducts/schema/dynamicfields/*_s' -H 'Content-type:application/json' --data-binary '{
"type": "text_general",
"stored": false
-}' "http://localhost:8983/api/collections/techproducts/schema/dynamicfields/*_s"
+}'
----
====
======
@@ -376,7 +376,7 @@ V2 API with Two Analyzers::
To define two analyzers with the V2 API, we just use a different endpoint:
[source,bash]
----
-curl -X PUT -H 'Content-type:application/json' --data-binary '{
+curl -X PUT 'http://localhost:8983/api/collections/techproducts/schema/fieldtypes/myNewTextField' -H 'Content-type:application/json' --data-binary '{
"class":"solr.TextField",
"indexAnalyzer":{
"tokenizer":{
@@ -385,7 +385,7 @@ curl -X PUT -H 'Content-type:application/json' --data-binary '{
"queryAnalyzer":{
"tokenizer":{
"name":"keyword" }}
-}' http://localhost:8983/api/collections/techproducts/schema/fieldtypes/myNewTextField
+}'
----
====
======
@@ -415,7 +415,7 @@ V2 API::
====
[source,bash]
----
-curl -X DELETE "http://localhost:8983/api/collections/techproducts/schema/fieldtypes/myNewTxtField"
+curl -X DELETE 'http://localhost:8983/api/collections/techproducts/schema/fieldtypes/myNewTxtField'
----
====
======
@@ -456,13 +456,13 @@ V2 API::
====
[source,bash]
----
-curl -X PUT -H 'Content-type:application/json' --data-binary '{
+curl -X PUT 'http://localhost:8983/api/collections/techproducts/schema/fieldtypes/myNewTxtField' -H 'Content-type:application/json' --data-binary '{
"class":"solr.TextField",
"positionIncrementGap":"100",
"analyzer":{
"tokenizer":{
"name":"standard" }}
-}' http://localhost:8983/api/collections/techproducts/schema/fieldtypes/myNewTxtField
+}'
----
====
======
@@ -490,6 +490,7 @@ s|Required |Default: none
|===
+
A field or an array of fields to which the source field will be copied.
+In the v2 API this attribute is named `destinations`; `dest` is still accepted as an alias.
`maxChars`::
+
@@ -523,11 +524,13 @@ V2 API::
====
[source,bash]
----
-curl 'http://localhost:8983/api/collections/techproducts/schema' -H 'Content-type:application/json' --data-binary '{
- "add-copy-field":{
- "source":"shelf",
- "dest":[ "location", "catchall" ]}
-}'
+curl 'http://localhost:8983/api/collections/techproducts/schema/bulk' -H 'Content-type:application/json' -d '[
+ {
+ "operationType":"add-copy-field",
+ "source":"shelf",
+ "destinations":[ "location", "catchall" ]
+ }
+]'
----
====
======
@@ -559,9 +562,9 @@ V2 API::
====
[source,bash]
----
-curl 'http://localhost:8983/api/collections/techproducts/schema' -H 'Content-type:application/json' --data-binary '{
- "delete-copy-field":{ "source":"shelf", "dest":"location" }
-}'
+curl 'http://localhost:8983/api/collections/techproducts/schema/bulk' -H 'Content-type:application/json' --data-binary '[
+ { "operationType":"delete-copy-field", "source":"shelf", "destinations":[ "location" ] }
+]'
----
====
======
@@ -636,27 +639,28 @@ curl 'http://localhost:8983/solr/techproducts/schema' -H 'Content-type:applicati
}'
----
-Bulk schema operations are also supported in Solr's v2 API, using a slightly different syntax.
+Bulk schema operations are also supported in Solr's v2 API, using a different endpoint and syntax.
+The v2 bulk endpoint is `POST /api/collections/_collection_/schema/bulk`; the `/schema` path itself only supports `GET` in v2.
Individual operations are specified as elements within a list, with the operation name (e.g. `add-field`, `delete-field-type`) specified as a `"operationType"` property on each operation object:
[source,bash]
----
-curl 'http://localhost:8983/solr/techproducts/schema/bulk' -H 'Content-type:application/json' --data-binary '
+curl 'http://localhost:8983/api/collections/techproducts/schema/bulk' -H 'Content-type:application/json' --data-binary '
[
{
- "operationType": "add-field"
+ "operationType": "add-field",
"name": "shelf",
"type": "myNewTxtField",
- "stored": true
+ "stored": true
},
{
- "operationType": "add-field"
+ "operationType": "add-field",
"name": "location",
"type": "myNewTxtField",
- "stored": true
+ "stored": true
},
{
- "operationType": "add-copy-field"
+ "operationType": "add-copy-field",
"source": "shelf",
"destinations": ["location", "catchall"]
}
@@ -729,7 +733,7 @@ Get the entire schema in JSON.
[source,bash]
----
-curl http://localhost:8983/solr/techproducts/schema
+curl 'http://localhost:8983/solr/techproducts/schema'
----
[source,json]
@@ -793,7 +797,7 @@ Get the entire schema in XML.
[source,bash]
----
-curl http://localhost:8983/solr/techproducts/schema?wt=xml
+curl 'http://localhost:8983/solr/techproducts/schema?wt=xml'
----
[source,xml]
@@ -847,7 +851,7 @@ Get the entire schema in "schema.xml" format.
[source,bash]
----
-curl http://localhost:8983/solr/techproducts/schema?wt=schema.xml
+curl 'http://localhost:8983/solr/techproducts/schema?wt=schema.xml'
----
[source,xml]
@@ -1212,7 +1216,7 @@ V1 API::
====
[source,bash]
----
-curl http://localhost:8983/solr/techproducts/schema/fieldtypes
+curl 'http://localhost:8983/solr/techproducts/schema/fieldtypes'
----
====
@@ -1335,7 +1339,7 @@ V1 API::
====
[source,bash]
----
-curl http://localhost:8983/solr/techproducts/schema/copyfields
+curl 'http://localhost:8983/solr/techproducts/schema/copyfields'
----
====
@@ -1425,7 +1429,7 @@ V1 API::
====
[source,bash]
----
-curl http://localhost:8983/solr/techproducts/schema/name
+curl 'http://localhost:8983/solr/techproducts/schema/name'
----
====
@@ -1495,7 +1499,7 @@ V1 API::
====
[source,bash]
----
-curl http://localhost:8983/solr/techproducts/schema/version
+curl 'http://localhost:8983/solr/techproducts/schema/version'
----
====
@@ -1564,7 +1568,7 @@ V1 API::
====
[source,bash]
----
-curl http://localhost:8983/solr/techproducts/schema/uniquekey
+curl 'http://localhost:8983/solr/techproducts/schema/uniquekey'
----
====
@@ -1633,7 +1637,7 @@ V1 API::
====
[source,bash]
----
-curl http://localhost:8983/solr/techproducts/schema/similarity
+curl 'http://localhost:8983/solr/techproducts/schema/similarity'
----
====
(solr) 10/10: SOLR-18493: Rename Index & Query section in new admin UI (#4994)
Posted by ab...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch branch_10_1
in repository https://gitbox.apache.org/repos/asf/solr.git
commit 02d093afcfa41c2237e6a07137d9cab24f33434b
Author: Jane Sandberg <sa...@users.noreply.github.com>
AuthorDate: Wed Oct 7 03:21:43 2026 -0700
SOLR-18493: Rename Index & Query section in new admin UI (#4994)
(cherry picked from commit 8f926b6532cdc625d11d91a1c99310c8de63e96f)
(cherry picked from commit 2bea0aef96587da6425433bbc6da6bdd203e94ba)
---
changelog/unreleased/SOLR-18493-rename-index-query-new-ui.yml | 7 +++++++
ui/shared/src/commonMain/composeResources/values/strings.xml | 2 +-
.../solr/ui/components/main/integration/DefaultMainComponent.kt | 4 ++--
.../kotlin/org/apache/solr/ui/views/navigation/MainMenu.kt | 2 +-
.../org/apache/solr/ui/views/navigation/NavigationSideBar.kt | 6 +++---
5 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/changelog/unreleased/SOLR-18493-rename-index-query-new-ui.yml b/changelog/unreleased/SOLR-18493-rename-index-query-new-ui.yml
new file mode 100644
index 00000000000..4aa6ca6af89
--- /dev/null
+++ b/changelog/unreleased/SOLR-18493-rename-index-query-new-ui.yml
@@ -0,0 +1,7 @@
+title: Rename Index & Query section in new admin UI
+type: changed
+authors:
+ - name: Jane Sandberg
+links:
+ - name: SOLR-18493
+ url: https://issues.apache.org/jira/browse/SOLR-18493
diff --git a/ui/shared/src/commonMain/composeResources/values/strings.xml b/ui/shared/src/commonMain/composeResources/values/strings.xml
index 57c9927b34e..1b28a6a8189 100644
--- a/ui/shared/src/commonMain/composeResources/values/strings.xml
+++ b/ui/shared/src/commonMain/composeResources/values/strings.xml
@@ -56,7 +56,7 @@
<string name="nav_environment">Environment</string>
<string name="nav_logging">Logging</string>
<string name="nav_metrics">Metrics</string>
- <string name="nav_queries_and_operations">Queries & Operations</string>
+ <string name="nav_index_and_query">Index & Query</string>
<string name="nav_security">Security</string>
<string name="nav_thread_dump">Thread Dump</string>
diff --git a/ui/shared/src/commonMain/kotlin/org/apache/solr/ui/components/main/integration/DefaultMainComponent.kt b/ui/shared/src/commonMain/kotlin/org/apache/solr/ui/components/main/integration/DefaultMainComponent.kt
index 1a354267c43..d3374d0b49a 100644
--- a/ui/shared/src/commonMain/kotlin/org/apache/solr/ui/components/main/integration/DefaultMainComponent.kt
+++ b/ui/shared/src/commonMain/kotlin/org/apache/solr/ui/components/main/integration/DefaultMainComponent.kt
@@ -192,7 +192,7 @@ class DefaultMainComponent internal constructor(
data object Collections : Configuration
@Serializable
- data object QueriesAndOperations : Configuration
+ data object IndexAndQuery : Configuration
@Serializable
data object Environment : Configuration
@@ -211,7 +211,7 @@ class DefaultMainComponent internal constructor(
MainMenu.Security -> Configuration.Security
MainMenu.Configsets -> Configuration.Configsets
MainMenu.Collections -> Configuration.Collections
- MainMenu.QueriesAndOperations -> Configuration.QueriesAndOperations
+ MainMenu.IndexAndQuery -> Configuration.IndexAndQuery
MainMenu.Environment -> Configuration.Environment
MainMenu.Logging -> Configuration.Logging
MainMenu.ThreadDump -> Configuration.ThreadDump
diff --git a/ui/shared/src/commonMain/kotlin/org/apache/solr/ui/views/navigation/MainMenu.kt b/ui/shared/src/commonMain/kotlin/org/apache/solr/ui/views/navigation/MainMenu.kt
index 91a11d2161a..c1791069082 100644
--- a/ui/shared/src/commonMain/kotlin/org/apache/solr/ui/views/navigation/MainMenu.kt
+++ b/ui/shared/src/commonMain/kotlin/org/apache/solr/ui/views/navigation/MainMenu.kt
@@ -31,7 +31,7 @@ enum class MainMenu {
Security,
Configsets,
Collections,
- QueriesAndOperations,
+ IndexAndQuery,
Environment,
Logging,
ThreadDump,
diff --git a/ui/shared/src/commonMain/kotlin/org/apache/solr/ui/views/navigation/NavigationSideBar.kt b/ui/shared/src/commonMain/kotlin/org/apache/solr/ui/views/navigation/NavigationSideBar.kt
index 86a5ada0eb4..06f79f96c2f 100644
--- a/ui/shared/src/commonMain/kotlin/org/apache/solr/ui/views/navigation/NavigationSideBar.kt
+++ b/ui/shared/src/commonMain/kotlin/org/apache/solr/ui/views/navigation/NavigationSideBar.kt
@@ -58,7 +58,7 @@ import org.apache.solr.ui.shared.generated.resources.nav_dashboard
import org.apache.solr.ui.shared.generated.resources.nav_environment
import org.apache.solr.ui.shared.generated.resources.nav_logging
import org.apache.solr.ui.shared.generated.resources.nav_metrics
-import org.apache.solr.ui.shared.generated.resources.nav_queries_and_operations
+import org.apache.solr.ui.shared.generated.resources.nav_index_and_query
import org.apache.solr.ui.shared.generated.resources.nav_security
import org.apache.solr.ui.shared.generated.resources.nav_thread_dump
import org.apache.solr.ui.shared.generated.resources.other_admission
@@ -177,7 +177,7 @@ private fun getMainMenuText(item: MainMenu) = when (item) {
MainMenu.Security -> Res.string.nav_security
MainMenu.Configsets -> Res.string.nav_configsets
MainMenu.Collections -> Res.string.nav_collections
- MainMenu.QueriesAndOperations -> Res.string.nav_queries_and_operations
+ MainMenu.IndexAndQuery -> Res.string.nav_index_and_query
MainMenu.Environment -> Res.string.nav_environment
MainMenu.Logging -> Res.string.nav_logging
MainMenu.ThreadDump -> Res.string.nav_thread_dump
@@ -200,7 +200,7 @@ private fun getMenuIcon(
MainMenu.Collections -> Res.drawable.apps
- MainMenu.QueriesAndOperations ->
+ MainMenu.IndexAndQuery ->
if (isSelected) Res.drawable.other_admission_filled else Res.drawable.other_admission
MainMenu.Environment -> if (isSelected) Res.drawable.memory_filled else Res.drawable.memory