Documentation
¶
Overview ¶
Package parent provides a retriever that maps sub-document results back to their original parent documents.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRetriever ¶
NewRetriever creates a new parent retriever that handles retrieving original documents based on sub-document search results.
Parameters:
- ctx: context for the operation
- config: configuration for the parent retriever
Example usage:
retriever, err := NewRetriever(ctx, &Config{
Retriever: milvusRetriever,
ParentIDKey: "source_doc_id",
OrigDocGetter: func(ctx context.Context, ids []string) ([]*schema.Document, error) {
return documentStore.GetByIDs(ctx, ids)
},
})
Returns:
- retriever.Retriever: the created parent retriever
- error: any error encountered during creation
Types ¶
type Config ¶
type Config struct {
// Retriever specifies the original retriever used to retrieve documents.
// For example: a vector database retriever like Milvus, or a full-text search retriever like Elasticsearch.
Retriever retriever.Retriever
// ParentIDKey specifies the key used in the sub-document metadata to store the parent document ID.
// Documents without this key will be removed from the recall results.
// For example: if ParentIDKey is "parent_id", it will look for metadata like:
// {"parent_id": "original_doc_123"}
ParentIDKey string
// OrigDocGetter specifies the method for getting original documents by ids from the sub-document metadata.
// Parameters:
// - ctx: context for the operation
// - ids: slice of parent document IDs to retrieve
// Returns:
// - []*schema.Document: slice of retrieved parent documents
// - error: any error encountered during retrieval
//
// For example: if sub-documents with parent IDs ["doc_1", "doc_2"] are retrieved,
// OrigDocGetter will be called to fetch the original documents with these IDs.
OrigDocGetter func(ctx context.Context, ids []string) ([]*schema.Document, error)
}
Config configures the parent retriever.
Click to show internal directories.
Click to hide internal directories.