From 7221d46b70e3f218e54387a8fa8990ddf2e2f31b Mon Sep 17 00:00:00 2001 From: Rahul Rampure Date: Mon, 27 Apr 2026 21:04:13 +0530 Subject: [PATCH] Fix `Size` calculation for `NestedDocuments` Co-authored-by: Copilot --- document/document.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/document/document.go b/document/document.go index 53033757b..cb3f53787 100644 --- a/document/document.go +++ b/document/document.go @@ -69,6 +69,12 @@ func (d *Document) Size() int { sizeInBytes += entry.Size() } + for _, entry := range d.NestedDocuments { + if entry != nil { + sizeInBytes += entry.Size() + } + } + return sizeInBytes } @@ -112,6 +118,11 @@ func (d *Document) NumPlainTextBytes() uint64 { } } } + for _, nestedDoc := range d.NestedDocuments { + if nestedDoc != nil { + rv += nestedDoc.NumPlainTextBytes() + } + } return rv }