parent

package
v0.3.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRetriever

func NewRetriever(ctx context.Context, config *Config) (retriever.Retriever, error)

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)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL