Skip to content
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.24

require (
github.com/RoaringBitmap/roaring/v2 v2.4.5
github.com/blevesearch/bleve_index_api v1.2.12-0.20260109154621-f19a6d6af728
github.com/blevesearch/bleve_index_api v1.2.12-0.20260109165046-049020a048f7
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ github.com/RoaringBitmap/roaring/v2 v2.4.5 h1:uGrrMreGjvAtTBobc0g5IrW1D5ldxDQYe2
github.com/RoaringBitmap/roaring/v2 v2.4.5/go.mod h1:FiJcsfkGje/nZBZgCu0ZxCPOKD/hVXDS2dXi7/eUFE0=
github.com/bits-and-blooms/bitset v1.12.0 h1:U/q1fAF7xXRhFCrhROzIfffYnu+dlS38vCZtmFVPHmA=
github.com/bits-and-blooms/bitset v1.12.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
github.com/blevesearch/bleve_index_api v1.2.12-0.20260109154621-f19a6d6af728 h1:qFnvr+SqVOCbhMl5sVynhuwVkv1yrc7Vhrn8lVdw1nU=
github.com/blevesearch/bleve_index_api v1.2.12-0.20260109154621-f19a6d6af728/go.mod h1:xvd48t5XMeeioWQ5/jZvgLrV98flT2rdvEJ3l/ki4Ko=
github.com/blevesearch/bleve_index_api v1.2.12-0.20260109165046-049020a048f7 h1:4sr3ewS5WzEDz9bwjQ4vrq/nIhBD1FXcCkvecd8OKfE=
github.com/blevesearch/bleve_index_api v1.2.12-0.20260109165046-049020a048f7/go.mod h1:xvd48t5XMeeioWQ5/jZvgLrV98flT2rdvEJ3l/ki4Ko=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down
21 changes: 21 additions & 0 deletions segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,24 @@ type Synonym interface {

Size() int
}

// NestedSegment is an optional interface that a Segment may implement
// to provide access to nested document relationships within that segment.
type NestedSegment interface {
Segment
// Ancestors returns a slice of ancestor IDs for the given document ID.
// If the document has no ancestors or if the segment does not support nested documents,
// a slice containing only the document ID itself is returned.
Ancestors(docID uint64, prealloc []index.AncestorID) []index.AncestorID

// CountRoot returns the number of root documents in the segment, excluding any documents
// that are marked as deleted in the provided bitmap. If the segment does not support nested
// documents, it returns the total document count minus the count of deleted documents.
// A root document is defined as a document that is not a child of any other document.
CountRoot(deleted *roaring.Bitmap) uint64

// AddNestedDocuments updates the provided bitmap to include all nested documents
// associated with documents marked as deleted in the bitmap. This ensures that when
// a parent document is deleted, all its nested child documents are also considered deleted.
AddNestedDocuments(deleted *roaring.Bitmap) *roaring.Bitmap
}
Loading