From fff8d1a84fcc0d2d3fd2a280c917567a1d94b82f Mon Sep 17 00:00:00 2001 From: Serhiy Bzhezytskyy Date: Fri, 21 Aug 2026 17:06:22 +0300 Subject: [PATCH 1/2] SOLR-18353: Remove deprecated SolrDocumentBase.getChildDocumentCount() Removed the method and its SolrDocument/SolrInputDocument overrides. Migrated 6 call sites to getChildDocuments().size(), null-checking where getChildDocuments() isn't already guarded by hasChildDocuments(). --- .../SOLR-18353-remove-getchilddocumentcount.yml | 10 ++++++++++ .../apache/solr/response/GeoJSONResponseWriter.java | 2 +- .../src/java/org/apache/solr/response/JSONWriter.java | 2 +- .../solr/search/join/TestCloudNestedDocsSort.java | 2 +- .../src/java/org/apache/solr/common/SolrDocument.java | 7 ------- .../java/org/apache/solr/common/SolrDocumentBase.java | 4 ---- .../java/org/apache/solr/common/SolrInputDocument.java | 6 ------ .../embedded/SolrExampleStreamingBinaryHttp2Test.java | 4 ++-- .../solrj/embedded/SolrExampleStreamingBinaryTest.java | 4 ++-- 9 files changed, 17 insertions(+), 24 deletions(-) create mode 100644 changelog/unreleased/SOLR-18353-remove-getchilddocumentcount.yml diff --git a/changelog/unreleased/SOLR-18353-remove-getchilddocumentcount.yml b/changelog/unreleased/SOLR-18353-remove-getchilddocumentcount.yml new file mode 100644 index 000000000000..4b5d6a349ecc --- /dev/null +++ b/changelog/unreleased/SOLR-18353-remove-getchilddocumentcount.yml @@ -0,0 +1,10 @@ +title: > + Removed the deprecated `SolrDocumentBase.getChildDocumentCount()` method (and its `SolrDocument`/ + `SolrInputDocument` overrides). Use `getChildDocuments().size()` instead (null-check first, since + `getChildDocuments()` may return `null` when there are no anonymous child documents). +type: removed +authors: + - name: Serhiy Bzhezytskyy +links: + - name: SOLR-18353 + url: https://issues.apache.org/jira/browse/SOLR-18353 diff --git a/solr/core/src/java/org/apache/solr/response/GeoJSONResponseWriter.java b/solr/core/src/java/org/apache/solr/response/GeoJSONResponseWriter.java index 3b0959e7a2db..b88eaf924f6e 100644 --- a/solr/core/src/java/org/apache/solr/response/GeoJSONResponseWriter.java +++ b/solr/core/src/java/org/apache/solr/response/GeoJSONResponseWriter.java @@ -174,8 +174,8 @@ public void writeSolrDocument(String name, SolrDocument doc, ReturnFields return indent(); } writeKey("_childDocuments_", true); - writeArrayOpener(doc.getChildDocumentCount()); List childDocs = doc.getChildDocuments(); + writeArrayOpener(childDocs.size()); for (int i = 0; i < childDocs.size(); i++) { writeSolrDocument(null, childDocs.get(i), null, i); } diff --git a/solr/core/src/java/org/apache/solr/response/JSONWriter.java b/solr/core/src/java/org/apache/solr/response/JSONWriter.java index bad358b0f5fa..e9eb78c9a362 100644 --- a/solr/core/src/java/org/apache/solr/response/JSONWriter.java +++ b/solr/core/src/java/org/apache/solr/response/JSONWriter.java @@ -116,8 +116,8 @@ public void writeSolrDocument(String name, SolrDocument doc, ReturnFields return indent(); } writeKey("_childDocuments_", true); - writeArrayOpener(doc.getChildDocumentCount()); List childDocs = doc.getChildDocuments(); + writeArrayOpener(childDocs.size()); for (int i = 0; i < childDocs.size(); i++) { writeSolrDocument(null, childDocs.get(i), null, i); } diff --git a/solr/core/src/test/org/apache/solr/search/join/TestCloudNestedDocsSort.java b/solr/core/src/test/org/apache/solr/search/join/TestCloudNestedDocsSort.java index 9921394e1367..40f16748840f 100644 --- a/solr/core/src/test/org/apache/solr/search/join/TestCloudNestedDocsSort.java +++ b/solr/core/src/test/org/apache/solr/search/join/TestCloudNestedDocsSort.java @@ -125,7 +125,7 @@ public static void setupCluster() throws Exception { matchingChild = chVals.iterator().next(); } } - maxDocs += parent.getChildDocumentCount() + 1; + maxDocs += (parent.hasChildDocuments() ? parent.getChildDocuments().size() : 0) + 1; docs.add(parent); } // don't add parents in increasing uniqueKey order diff --git a/solr/solrj/src/java/org/apache/solr/common/SolrDocument.java b/solr/solrj/src/java/org/apache/solr/common/SolrDocument.java index 53a152cfcd55..e363352fe6ab 100644 --- a/solr/solrj/src/java/org/apache/solr/common/SolrDocument.java +++ b/solr/solrj/src/java/org/apache/solr/common/SolrDocument.java @@ -482,11 +482,4 @@ public boolean hasChildDocuments() { boolean isEmpty = (_childDocuments == null || _childDocuments.isEmpty()); return !isEmpty; } - - @Override - @Deprecated - public int getChildDocumentCount() { - if (_childDocuments == null) return 0; - return _childDocuments.size(); - } } diff --git a/solr/solrj/src/java/org/apache/solr/common/SolrDocumentBase.java b/solr/solrj/src/java/org/apache/solr/common/SolrDocumentBase.java index c3102d2a3bb9..59c4c0557e56 100644 --- a/solr/solrj/src/java/org/apache/solr/common/SolrDocumentBase.java +++ b/solr/solrj/src/java/org/apache/solr/common/SolrDocumentBase.java @@ -63,8 +63,4 @@ public abstract class SolrDocumentBase implements Map, Serializ /** Has anonymous children? */ public abstract boolean hasChildDocuments(); - - /** The anonymous child document count. */ - @Deprecated - public abstract int getChildDocumentCount(); } diff --git a/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java b/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java index 4ae3f35eff55..505de256afe7 100644 --- a/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java +++ b/solr/solrj/src/java/org/apache/solr/common/SolrInputDocument.java @@ -317,10 +317,4 @@ public boolean hasChildDocuments() { boolean isEmpty = (_childDocuments == null || _childDocuments.isEmpty()); return !isEmpty; } - - @Override - @Deprecated - public int getChildDocumentCount() { - return hasChildDocuments() ? _childDocuments.size() : 0; - } } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryHttp2Test.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryHttp2Test.java index d735eac50038..439351c896b5 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryHttp2Test.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryHttp2Test.java @@ -79,7 +79,7 @@ public void testQueryAndStreamResponse() throws Exception { QueryResponse response = client.query(query); assertEquals(1, response.getResults().size()); SolrDocument parentDoc = response.getResults().get(0); - assertEquals(1, parentDoc.getChildDocumentCount()); + assertEquals(1, parentDoc.getChildDocuments().size()); // test streaming final List docs = new ArrayList<>(); @@ -97,6 +97,6 @@ public void streamDocListInfo(long numFound, long start, Float maxScore) {} assertEquals(1, docs.size()); parentDoc = docs.get(0); - assertEquals(1, parentDoc.getChildDocumentCount()); + assertEquals(1, parentDoc.getChildDocuments().size()); } } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryTest.java index 32aa7164cd12..3e963505d9fe 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/embedded/SolrExampleStreamingBinaryTest.java @@ -78,7 +78,7 @@ public void testQueryAndStreamResponse() throws Exception { QueryResponse response = client.query(query); assertEquals(1, response.getResults().size()); SolrDocument parentDoc = response.getResults().get(0); - assertEquals(1, parentDoc.getChildDocumentCount()); + assertEquals(1, parentDoc.getChildDocuments().size()); // test streaming final List docs = new ArrayList<>(); @@ -96,6 +96,6 @@ public void streamDocListInfo(long numFound, long start, Float maxScore) {} assertEquals(1, docs.size()); parentDoc = docs.get(0); - assertEquals(1, parentDoc.getChildDocumentCount()); + assertEquals(1, parentDoc.getChildDocuments().size()); } } From bcec5bf50a2e84c16111dada8ceb17a354361d59 Mon Sep 17 00:00:00 2001 From: Serhiy Bzhezytskyy Date: Sat, 22 Aug 2026 08:50:45 +0300 Subject: [PATCH 2/2] SOLR-18353: drop the changelog entry David: 'Please remove the changelog. Too niche/bespoke of a method.' --- .../SOLR-18353-remove-getchilddocumentcount.yml | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 changelog/unreleased/SOLR-18353-remove-getchilddocumentcount.yml diff --git a/changelog/unreleased/SOLR-18353-remove-getchilddocumentcount.yml b/changelog/unreleased/SOLR-18353-remove-getchilddocumentcount.yml deleted file mode 100644 index 4b5d6a349ecc..000000000000 --- a/changelog/unreleased/SOLR-18353-remove-getchilddocumentcount.yml +++ /dev/null @@ -1,10 +0,0 @@ -title: > - Removed the deprecated `SolrDocumentBase.getChildDocumentCount()` method (and its `SolrDocument`/ - `SolrInputDocument` overrides). Use `getChildDocuments().size()` instead (null-check first, since - `getChildDocuments()` may return `null` when there are no anonymous child documents). -type: removed -authors: - - name: Serhiy Bzhezytskyy -links: - - name: SOLR-18353 - url: https://issues.apache.org/jira/browse/SOLR-18353