Skip to content

SOLR-18353: Remove deprecated SolrDocumentBase.getChildDocumentCount() - #4785

Open
serhiy-bzhezytskyy wants to merge 1 commit into
apache:mainfrom
serhiy-bzhezytskyy:SOLR-18353-remove-getchilddocumentcount
Open

SOLR-18353: Remove deprecated SolrDocumentBase.getChildDocumentCount()#4785
serhiy-bzhezytskyy wants to merge 1 commit into
apache:mainfrom
serhiy-bzhezytskyy:SOLR-18353-remove-getchilddocumentcount

Conversation

@serhiy-bzhezytskyy

Copy link
Copy Markdown
Contributor

https://issues.apache.org/jira/browse/SOLR-18353

Removed getChildDocumentCount() from SolrDocumentBase and its overrides in SolrDocument/SolrInputDocument, and migrated all callers to getChildDocuments().size().

One thing worth flagging: getChildDocuments() returns null when there are no anonymous children, so getChildDocuments().size() isn't a safe drop-in everywhere -- the removed method existed partly to hide that null-check. Handled per call site:

  • JSONWriter/GeoJSONResponseWriter: already inside an if (doc.hasChildDocuments()) guard with childDocs = doc.getChildDocuments() fetched right after -- reordered to fetch childDocs first and pass childDocs.size(), which also removes a redundant second call to getChildDocuments().
  • SolrExampleStreamingBinaryTest/Http2Test (4 sites): assertEquals(1, ...) right after adding exactly one child -- safe as a bare .getChildDocuments().size().
  • TestCloudNestedDocsSort: children are added conditionally in a loop and may never be added -- kept the null-safe ternary (hasChildDocuments() ? getChildDocuments().size() : 0).

Changelog added (type: removed).

Tests: TestChildDocTransformer, TestCloudNestedDocsSort, SolrExampleStreamingBinaryTest, SolrExampleStreamingBinaryHttp2Test all green.

AI-assisted (Claude Sonnet 5)

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().

@epugh epugh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, this at least seemed pretty straightforward removal!

@epugh

epugh commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

I wonder if getChildDocuments should return an empty list if there are no child docs instead of null? WDYT @dsmiley ?

@dsmiley dsmiley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

Please remove the changelog. Too niche/bespoke of a method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants