Documentation
¶
Index ¶
- Constants
- func DetectChunking(file string) (types.Chunking, error)
- func DetectConverter(file string) (types.Converter, error)
- func DetectEmbedding(file string) (types.Embedding, error)
- func DetectExtractor(file string) (types.Extraction, error)
- func DetectFetcher(url string) (types.Fetcher, error)
- func MakeUpsertCallback(id string, chunks *[]*types.Chunk, cb types.UpsertProgress) types.UpsertCallback
- type Config
- type EntityDeduplicationResult
- type GraphRag
- func (g *GraphRag) AddFile(ctx context.Context, file string, options *types.UpsertOptions) (string, error)
- func (g *GraphRag) AddSegments(ctx context.Context, docID string, segmentTexts []types.SegmentText, ...) ([]string, error)
- func (g *GraphRag) AddStream(ctx context.Context, stream io.ReadSeeker, options *types.UpsertOptions) (string, error)
- func (g *GraphRag) AddText(ctx context.Context, text string, options *types.UpsertOptions) (string, error)
- func (g *GraphRag) AddURL(ctx context.Context, url string, options *types.UpsertOptions) (string, error)
- func (g *GraphRag) Backup(ctx context.Context, writer io.Writer, id string) error
- func (g *GraphRag) CollectionExists(ctx context.Context, id string) (bool, error)
- func (g *GraphRag) CreateCollection(ctx context.Context, collection types.CollectionConfig) (string, error)
- func (g *GraphRag) ExtractSegmentGraph(ctx context.Context, docID string, segmentID string, ...) (*types.SegmentExtractionResult, error)
- func (g *GraphRag) GetCollection(ctx context.Context, id string) (*types.CollectionInfo, error)
- func (g *GraphRag) GetCollections(ctx context.Context, filter map[string]interface{}) ([]types.CollectionInfo, error)
- func (g *GraphRag) GetHit(ctx context.Context, docID string, segmentID string, hitID string) (*types.SegmentHit, error)
- func (g *GraphRag) GetSegment(ctx context.Context, docID string, segmentID string) (*types.Segment, error)
- func (g *GraphRag) GetSegmentEntities(ctx context.Context, docID string, segmentID string) ([]types.GraphNode, error)
- func (g *GraphRag) GetSegmentGraph(ctx context.Context, docID string, segmentID string) (*types.SegmentGraph, error)
- func (g *GraphRag) GetSegmentParents(ctx context.Context, docID string, segmentID string) (*types.SegmentTree, error)
- func (g *GraphRag) GetSegmentRelationships(ctx context.Context, docID string, segmentID string) ([]types.GraphRelationship, error)
- func (g *GraphRag) GetSegmentRelationshipsByEntities(ctx context.Context, docID string, segmentID string) ([]types.GraphRelationship, error)
- func (g *GraphRag) GetSegments(ctx context.Context, docID string, segmentIDs []string) ([]types.Segment, error)
- func (g *GraphRag) GetVote(ctx context.Context, docID string, segmentID string, voteID string) (*types.SegmentVote, error)
- func (g *GraphRag) ListSegments(ctx context.Context, docID string, options *types.ListSegmentsOptions) (*types.PaginatedSegmentsResult, error)
- func (g *GraphRag) MultiSearch(ctx context.Context, options []types.QueryOptions, ...) (map[string][]types.Segment, error)
- func (g *GraphRag) RemoveCollection(ctx context.Context, id string) (bool, error)
- func (g *GraphRag) RemoveDocs(ctx context.Context, ids []string) (int, error)
- func (g *GraphRag) RemoveHits(ctx context.Context, docID string, hits []types.HitRemoval) (int, error)
- func (g *GraphRag) RemoveHitsBySegmentID(ctx context.Context, docID string, segmentID string) (int, error)
- func (g *GraphRag) RemoveSegments(ctx context.Context, docID string, segmentIDs []string) (int, error)
- func (g *GraphRag) RemoveSegmentsByDocID(ctx context.Context, docID string) (int, error)
- func (g *GraphRag) RemoveVotes(ctx context.Context, docID string, votes []types.VoteRemoval) (int, error)
- func (g *GraphRag) RemoveVotesBySegmentID(ctx context.Context, docID string, segmentID string) (int, error)
- func (g *GraphRag) Restore(ctx context.Context, reader io.Reader, id string) error
- func (g *GraphRag) ScrollHits(ctx context.Context, docID string, options *types.ScrollHitsOptions) (*types.HitScrollResult, error)
- func (g *GraphRag) ScrollSegments(ctx context.Context, docID string, options *types.ScrollSegmentsOptions) (*types.SegmentScrollResult, error)
- func (g *GraphRag) ScrollVotes(ctx context.Context, docID string, options *types.ScrollVotesOptions) (*types.VoteScrollResult, error)
- func (g *GraphRag) Search(ctx context.Context, options *types.QueryOptions, ...) ([]types.Segment, error)
- func (g *GraphRag) SearchGraph(ctx context.Context, options *types.GraphSearchOptions, ...) (*types.GraphSearchResult, error)
- func (g *GraphRag) SearchVector(ctx context.Context, options *types.VectorSearchOptions, ...) (*types.VectorSearchResult, error)
- func (g *GraphRag) SegmentCount(ctx context.Context, docID string) (int, error)
- func (g *GraphRag) UpdateCollectionMetadata(ctx context.Context, id string, metadata map[string]interface{}) error
- func (g *GraphRag) UpdateHits(ctx context.Context, docID string, segments []types.SegmentHit, ...) (int, error)
- func (g *GraphRag) UpdateScores(ctx context.Context, docID string, segments []types.SegmentScore, ...) (int, error)
- func (g *GraphRag) UpdateSegments(ctx context.Context, segmentTexts []types.SegmentText, ...) (int, error)
- func (g *GraphRag) UpdateVotes(ctx context.Context, docID string, segments []types.SegmentVote, ...) (int, error)
- func (g *GraphRag) UpdateWeights(ctx context.Context, docID string, segments []types.SegmentWeight, ...) (int, error)
- func (g *GraphRag) WithGraph(graph types.GraphStore) *GraphRag
- func (g *GraphRag) WithLogger(logger types.Logger) *GraphRag
- func (g *GraphRag) WithStore(store store.Store) *GraphRag
- func (g *GraphRag) WithSystem(system string) *GraphRag
- type RelationshipDeduplicationResult
- type StoreDocumentsOptions
Constants ¶
const StoreKeyHit = "doc:%s:segment:hits:%s" // doc:{docID}:segment:hits:{segmentID}
StoreKeyHit key format for hit storage (List)
const StoreKeyHitCount = "doc:%s:segment:hit:count:%s" // doc:{docID}:segment:hit:count:{segmentID}
StoreKeyHitCount key format for hit count storage
const (
StoreKeyOrigin = "origin_%s" // origin_{docID}
)
Store key formats (without docID to reduce queries)
const StoreKeyScore = "doc:%s:segment:score:%s" // doc:{docID}:segment:score:{segmentID}
StoreKeyScore key format for score storage
const StoreKeyScoreDimensions = "doc:%s:segment:score:dimensions:%s" // doc:{docID}:segment:score:dimensions:{segmentID}
StoreKeyScoreDimensions key format for score dimensions storage
const StoreKeyVote = "doc:%s:segment:votes:%s" // doc:{docID}:segment:votes:{segmentID}
StoreKeyVote key format for vote storage (List)
const StoreKeyVoteNegative = "doc:%s:segment:negative:%s" // doc:{docID}:segment:negative:{segmentID}
StoreKeyVoteNegative key format for negative vote count storage
const StoreKeyVotePositive = "doc:%s:segment:positive:%s" // doc:{docID}:segment:positive:{segmentID}
StoreKeyVotePositive key format for positive vote count storage
const StoreKeyWeight = "doc:%s:segment:weight:%s" // doc:{docID}:segment:weight:{segmentID}
StoreKeyWeight key format for weight storage
Variables ¶
This section is empty.
Functions ¶
func DetectChunking ¶
DetectChunking detects the chunking function to use for the file
func DetectConverter ¶
DetectConverter detects the converter to use for the file
func DetectEmbedding ¶
DetectEmbedding detects the embedding function to use for the file
func DetectExtractor ¶
func DetectExtractor(file string) (types.Extraction, error)
DetectExtractor detects the extractor function to use for the file
func DetectFetcher ¶
DetectFetcher detects the fetcher to use for the URL
Supported fetchers: - HTTP/HTTPS: Uses optimized gou/http package with DNS optimization and connection pooling - MCP: Uses MCP client for custom URL fetching (requires manual configuration)
For MCP fetcher, use fetcher.NewMCP() with appropriate MCPOptions
func MakeUpsertCallback ¶
func MakeUpsertCallback(id string, chunks *[]*types.Chunk, cb types.UpsertProgress) types.UpsertCallback
MakeUpsertCallback creates a new UpsertCallback
Types ¶
type Config ¶
type Config struct {
Logger types.Logger
Vector types.VectorStore // Vector Store for Embedding, Search, Rerank
Graph types.GraphStore // Graph Store for GraphRAG
Store store.Store // For Collection Metadata, Vote, Score, Weight history etc.
System string // System Collection name for internal metadata
}
Config is the configuration for the GraphRag instance
type EntityDeduplicationResult ¶
EntityDeduplicationResult contains the result of entity deduplication
type GraphRag ¶
type GraphRag struct {
Vector types.VectorStore
Graph types.GraphStore
Store store.Store
Logger types.Logger
System string // System Collection name for internal metadata
}
GraphRag is the main struct for the GraphRag system
func (*GraphRag) AddFile ¶
func (g *GraphRag) AddFile(ctx context.Context, file string, options *types.UpsertOptions) (string, error)
AddFile adds a file to a collection
func (*GraphRag) AddSegments ¶
func (g *GraphRag) AddSegments(ctx context.Context, docID string, segmentTexts []types.SegmentText, options *types.UpsertOptions) ([]string, error)
AddSegments adds segments to a collection manually
func (*GraphRag) AddStream ¶
func (g *GraphRag) AddStream(ctx context.Context, stream io.ReadSeeker, options *types.UpsertOptions) (string, error)
AddStream adds a stream to a collection
func (*GraphRag) AddText ¶
func (g *GraphRag) AddText(ctx context.Context, text string, options *types.UpsertOptions) (string, error)
AddText adds a text to a collection
func (*GraphRag) AddURL ¶
func (g *GraphRag) AddURL(ctx context.Context, url string, options *types.UpsertOptions) (string, error)
AddURL adds a URL to a collection
func (*GraphRag) CollectionExists ¶
CollectionExists checks if a collection exists
func (*GraphRag) CreateCollection ¶
func (g *GraphRag) CreateCollection(ctx context.Context, collection types.CollectionConfig) (string, error)
CreateCollection creates a new collection
func (*GraphRag) ExtractSegmentGraph ¶
func (g *GraphRag) ExtractSegmentGraph(ctx context.Context, docID string, segmentID string, options *types.ExtractionOptions) (*types.SegmentExtractionResult, error)
ExtractSegmentGraph re-extracts entities and relationships for a specific segment
func (*GraphRag) GetCollection ¶
GetCollection gets a single collection by ID
func (*GraphRag) GetCollections ¶
func (g *GraphRag) GetCollections(ctx context.Context, filter map[string]interface{}) ([]types.CollectionInfo, error)
GetCollections gets all collections with optional metadata filtering
func (*GraphRag) GetHit ¶
func (g *GraphRag) GetHit(ctx context.Context, docID string, segmentID string, hitID string) (*types.SegmentHit, error)
GetHit gets a single hit by ID
func (*GraphRag) GetSegment ¶
func (g *GraphRag) GetSegment(ctx context.Context, docID string, segmentID string) (*types.Segment, error)
GetSegment gets a single segment by ID
func (*GraphRag) GetSegmentEntities ¶
func (g *GraphRag) GetSegmentEntities(ctx context.Context, docID string, segmentID string) ([]types.GraphNode, error)
GetSegmentEntities gets the entities for a specific segment
func (*GraphRag) GetSegmentGraph ¶
func (g *GraphRag) GetSegmentGraph(ctx context.Context, docID string, segmentID string) (*types.SegmentGraph, error)
GetSegmentGraph gets the graph information (entities and relationships) for a specific segment
func (*GraphRag) GetSegmentParents ¶
func (g *GraphRag) GetSegmentParents(ctx context.Context, docID string, segmentID string) (*types.SegmentTree, error)
GetSegmentParents gets parent tree of a given segment
func (*GraphRag) GetSegmentRelationships ¶
func (g *GraphRag) GetSegmentRelationships(ctx context.Context, docID string, segmentID string) ([]types.GraphRelationship, error)
GetSegmentRelationships gets the relationships for a specific segment
func (*GraphRag) GetSegmentRelationshipsByEntities ¶
func (g *GraphRag) GetSegmentRelationshipsByEntities(ctx context.Context, docID string, segmentID string) ([]types.GraphRelationship, error)
GetSegmentRelationshipsByEntities gets all relationships connected to entities in this segment This method finds all relationships that involve entities from the segment, regardless of where the relationship was originally extracted
func (*GraphRag) GetSegments ¶
func (g *GraphRag) GetSegments(ctx context.Context, docID string, segmentIDs []string) ([]types.Segment, error)
GetSegments gets segments by IDs
func (*GraphRag) GetVote ¶
func (g *GraphRag) GetVote(ctx context.Context, docID string, segmentID string, voteID string) (*types.SegmentVote, error)
GetVote gets a single vote by ID
func (*GraphRag) ListSegments ¶
func (g *GraphRag) ListSegments(ctx context.Context, docID string, options *types.ListSegmentsOptions) (*types.PaginatedSegmentsResult, error)
ListSegments lists segments of a document with pagination (deprecated)
func (*GraphRag) MultiSearch ¶
func (g *GraphRag) MultiSearch(ctx context.Context, options []types.QueryOptions, callback ...types.SearcherProgress) (map[string][]types.Segment, error)
MultiSearch performs multiple searches in parallel and returns results grouped by query
func (*GraphRag) RemoveCollection ¶
RemoveCollection removes a collection
func (*GraphRag) RemoveDocs ¶
RemoveDocs removes documents by IDs
func (*GraphRag) RemoveHits ¶
func (g *GraphRag) RemoveHits(ctx context.Context, docID string, hits []types.HitRemoval) (int, error)
RemoveHits removes multiple hits by HitID and updates statistics
func (*GraphRag) RemoveHitsBySegmentID ¶
func (g *GraphRag) RemoveHitsBySegmentID(ctx context.Context, docID string, segmentID string) (int, error)
RemoveHitsBySegmentID removes all hits for a segment and clears statistics
func (*GraphRag) RemoveSegments ¶
func (g *GraphRag) RemoveSegments(ctx context.Context, docID string, segmentIDs []string) (int, error)
RemoveSegments removes segments by IDs
func (*GraphRag) RemoveSegmentsByDocID ¶
RemoveSegmentsByDocID removes all segments of a document
func (*GraphRag) RemoveVotes ¶
func (g *GraphRag) RemoveVotes(ctx context.Context, docID string, votes []types.VoteRemoval) (int, error)
RemoveVotes removes multiple votes by VoteID and updates statistics
func (*GraphRag) RemoveVotesBySegmentID ¶
func (g *GraphRag) RemoveVotesBySegmentID(ctx context.Context, docID string, segmentID string) (int, error)
RemoveVotesBySegmentID removes all votes for a segment and clears statistics
func (*GraphRag) ScrollHits ¶
func (g *GraphRag) ScrollHits(ctx context.Context, docID string, options *types.ScrollHitsOptions) (*types.HitScrollResult, error)
ScrollHits scrolls hits for a document with pagination support
func (*GraphRag) ScrollSegments ¶
func (g *GraphRag) ScrollSegments(ctx context.Context, docID string, options *types.ScrollSegmentsOptions) (*types.SegmentScrollResult, error)
ScrollSegments scrolls through segments of a document with iterator-style pagination
func (*GraphRag) ScrollVotes ¶
func (g *GraphRag) ScrollVotes(ctx context.Context, docID string, options *types.ScrollVotesOptions) (*types.VoteScrollResult, error)
ScrollVotes scrolls votes for a document with pagination support
func (*GraphRag) Search ¶
func (g *GraphRag) Search(ctx context.Context, options *types.QueryOptions, callback ...types.SearcherProgress) ([]types.Segment, error)
Search searches for segments based on query options It performs vector similarity search and optionally enriches results with graph data
func (*GraphRag) SearchGraph ¶
func (g *GraphRag) SearchGraph(ctx context.Context, options *types.GraphSearchOptions, callback ...types.SearcherProgress) (*types.GraphSearchResult, error)
SearchGraph performs pure graph/knowledge search without vector similarity This is useful for application-side orchestration where vector and graph searches are composed separately
func (*GraphRag) SearchVector ¶
func (g *GraphRag) SearchVector(ctx context.Context, options *types.VectorSearchOptions, callback ...types.SearcherProgress) (*types.VectorSearchResult, error)
SearchVector performs pure vector similarity search without graph enrichment This is useful for application-side orchestration where vector and graph searches are composed separately
func (*GraphRag) SegmentCount ¶
SegmentCount returns the number of segments for a given document
func (*GraphRag) UpdateCollectionMetadata ¶
func (g *GraphRag) UpdateCollectionMetadata(ctx context.Context, id string, metadata map[string]interface{}) error
UpdateCollectionMetadata updates the metadata of an existing collection
func (*GraphRag) UpdateHits ¶
func (g *GraphRag) UpdateHits(ctx context.Context, docID string, segments []types.SegmentHit, options ...types.UpdateHitOptions) (int, error)
UpdateHits updates hit for segments
func (*GraphRag) UpdateScores ¶
func (g *GraphRag) UpdateScores(ctx context.Context, docID string, segments []types.SegmentScore, options ...types.UpdateScoreOptions) (int, error)
UpdateScores updates score for segments
func (*GraphRag) UpdateSegments ¶
func (g *GraphRag) UpdateSegments(ctx context.Context, segmentTexts []types.SegmentText, options *types.UpsertOptions) (int, error)
UpdateSegments updates segments manually
func (*GraphRag) UpdateVotes ¶
func (g *GraphRag) UpdateVotes(ctx context.Context, docID string, segments []types.SegmentVote, options ...types.UpdateVoteOptions) (int, error)
UpdateVotes updates vote for segments
func (*GraphRag) UpdateWeights ¶
func (g *GraphRag) UpdateWeights(ctx context.Context, docID string, segments []types.SegmentWeight, options ...types.UpdateWeightOptions) (int, error)
UpdateWeights updates weight for segments
func (*GraphRag) WithGraph ¶
func (g *GraphRag) WithGraph(graph types.GraphStore) *GraphRag
WithGraph sets the graph store for the GraphRag instance
func (*GraphRag) WithLogger ¶
WithLogger sets the logger for the GraphRag instance
func (*GraphRag) WithSystem ¶
WithSystem sets the system collection name for the GraphRag instance
type RelationshipDeduplicationResult ¶
RelationshipDeduplicationResult contains the result of relationship deduplication
type StoreDocumentsOptions ¶
type StoreDocumentsOptions struct {
Chunks []*types.Chunk
Entities []types.Node
Relationships []types.Relationship
Embeddings *types.EmbeddingResults
EmbeddingIndexesMap map[*types.Chunk]int
EntityIndexMap map[*types.Node]int
RelationshipIndexMap map[*types.Relationship]int
SourceFile string
ConvertMetadata map[string]interface{}
UserMetadata map[string]interface{}
VectorCollectionName string
CollectionID string
DocID string // Add document ID for tracking
EntityDeduplicationResults map[string]*EntityDeduplicationResult
RelationshipDeduplicationResults map[string]*RelationshipDeduplicationResult
OriginalText string // Add original text for potential Vector DB storage
}
StoreDocumentsOptions contains all options for storing documents to vector store