Documentation
¶
Index ¶
- type Adapter
- func (a *Adapter) Close(ctx context.Context) error
- func (a *Adapter) CreateDocument(ctx context.Context, collectionName string, document *vectordb.Document) error
- func (a *Adapter) CreateDocuments(ctx context.Context, collectionName string, documents []*vectordb.Document) error
- func (a *Adapter) SearchSemantic(ctx context.Context, collectionName, query string, opts *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)
- type Client
- func (c *Client) Close(ctx context.Context) error
- func (c *Client) CollectionExists(ctx context.Context, name string) (bool, error)
- func (c *Client) CreateCollection(ctx context.Context, name string, schema *vectordb.CollectionSchema) error
- func (c *Client) DeleteAllDocuments(ctx context.Context, collectionName string) error
- func (c *Client) DeleteCollection(ctx context.Context, name string) error
- func (c *Client) DeleteDocument(ctx context.Context, collectionName, documentID string) error
- func (c *Client) DeleteDocuments(ctx context.Context, collectionName string, documentIDs []string) error
- func (c *Client) DeleteDocumentsByMetadata(ctx context.Context, collectionName string, metadata map[string]interface{}) error
- func (c *Client) GetCollectionCount(ctx context.Context, name string) (int64, error)
- func (c *Client) GetDefaultSchema(schemaType vectordb.SchemaType, collectionName string) *vectordb.CollectionSchema
- func (c *Client) GetDocument(ctx context.Context, collectionName, documentID string) (*vectordb.Document, error)
- func (c *Client) GetSchema(ctx context.Context, collectionName string) (*vectordb.CollectionSchema, error)
- func (c *Client) Health(ctx context.Context) error
- func (c *Client) ListCollections(ctx context.Context) ([]vectordb.CollectionInfo, error)
- func (c *Client) ListDocuments(ctx context.Context, collectionName string, limit int, offset int) ([]*vectordb.Document, error)
- func (c *Client) SearchBM25(ctx context.Context, collectionName, query string, opts *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)
- func (c *Client) SearchByMetadata(ctx context.Context, collectionName string, metadata map[string]interface{}, ...) ([]*vectordb.QueryResult, error)
- func (c *Client) SearchHybrid(ctx context.Context, collectionName, query string, opts *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)
- func (c *Client) UpdateDocument(ctx context.Context, collectionName string, document *vectordb.Document) error
- func (c *Client) UpdateSchema(ctx context.Context, collectionName string, schema *vectordb.CollectionSchema) error
- func (c *Client) ValidateSchema(schema *vectordb.CollectionSchema) error
- type Config
- type Factory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
*Client
// contains filtered or unexported fields
}
Adapter wraps the MongoDB client to implement the vectordb.VectorDBClient interface
func NewAdapter ¶
NewAdapter creates a new MongoDB adapter from the vectordb.Config
func (*Adapter) CreateDocument ¶
func (a *Adapter) CreateDocument(ctx context.Context, collectionName string, document *vectordb.Document) error
CreateDocument creates a new document in the specified collection
func (*Adapter) CreateDocuments ¶
func (a *Adapter) CreateDocuments(ctx context.Context, collectionName string, documents []*vectordb.Document) error
CreateDocuments creates multiple documents in batch
func (*Adapter) SearchSemantic ¶
func (a *Adapter) SearchSemantic(ctx context.Context, collectionName, query string, opts *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)
SearchSemantic performs semantic search using MongoDB Atlas Vector Search
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the MongoDB client with vector database functionality
func (*Client) CollectionExists ¶
CollectionExists checks if a collection exists
func (*Client) CreateCollection ¶
func (c *Client) CreateCollection(ctx context.Context, name string, schema *vectordb.CollectionSchema) error
CreateCollection creates a new collection with Atlas Vector Search index
func (*Client) DeleteAllDocuments ¶
DeleteAllDocuments deletes all documents in a collection
func (*Client) DeleteCollection ¶
DeleteCollection deletes a collection and all its documents
func (*Client) DeleteDocument ¶
DeleteDocument deletes a document by ID
func (*Client) DeleteDocuments ¶
func (c *Client) DeleteDocuments(ctx context.Context, collectionName string, documentIDs []string) error
DeleteDocuments deletes multiple documents by IDs
func (*Client) DeleteDocumentsByMetadata ¶
func (c *Client) DeleteDocumentsByMetadata(ctx context.Context, collectionName string, metadata map[string]interface{}) error
DeleteDocumentsByMetadata deletes documents matching metadata criteria
func (*Client) GetCollectionCount ¶
GetCollectionCount returns the number of documents in a collection
func (*Client) GetDefaultSchema ¶
func (c *Client) GetDefaultSchema(schemaType vectordb.SchemaType, collectionName string) *vectordb.CollectionSchema
GetDefaultSchema returns a default schema for the given type
func (*Client) GetDocument ¶
func (c *Client) GetDocument(ctx context.Context, collectionName, documentID string) (*vectordb.Document, error)
GetDocument retrieves a document by ID
func (*Client) GetSchema ¶
func (c *Client) GetSchema(ctx context.Context, collectionName string) (*vectordb.CollectionSchema, error)
GetSchema retrieves the schema for a collection Note: MongoDB is schema-less, so we return a default schema
func (*Client) ListCollections ¶
ListCollections returns a list of all collections
func (*Client) ListDocuments ¶
func (c *Client) ListDocuments(ctx context.Context, collectionName string, limit int, offset int) ([]*vectordb.Document, error)
ListDocuments returns a list of documents in a collection
func (*Client) SearchBM25 ¶
func (c *Client) SearchBM25(ctx context.Context, collectionName, query string, opts *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)
SearchBM25 performs keyword-based search using MongoDB text search
func (*Client) SearchByMetadata ¶
func (c *Client) SearchByMetadata(ctx context.Context, collectionName string, metadata map[string]interface{}, opts *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)
SearchByMetadata searches documents by metadata fields
func (*Client) SearchHybrid ¶
func (c *Client) SearchHybrid(ctx context.Context, collectionName, query string, opts *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)
SearchHybrid performs hybrid search combining vector and keyword search
func (*Client) UpdateDocument ¶
func (c *Client) UpdateDocument(ctx context.Context, collectionName string, document *vectordb.Document) error
UpdateDocument updates an existing document
func (*Client) UpdateSchema ¶
func (c *Client) UpdateSchema(ctx context.Context, collectionName string, schema *vectordb.CollectionSchema) error
UpdateSchema updates the schema for a collection Note: MongoDB is schema-less, so this is a no-op
func (*Client) ValidateSchema ¶
func (c *Client) ValidateSchema(schema *vectordb.CollectionSchema) error
ValidateSchema validates a schema definition
type Config ¶
type Config struct {
// Connection settings
URI string // MongoDB connection URI (mongodb+srv://...)
Database string // Database name
Timeout int // Timeout in seconds for operations (default: 10)
// Vector search settings
VectorDimensions int // Embedding vector dimensions (e.g., 1536 for OpenAI)
SimilarityMetric string // Similarity metric: "cosine", "euclidean", or "dotProduct"
}
Config holds MongoDB client configuration
type Factory ¶
type Factory struct{}
Factory implements the ClientFactory interface for MongoDB
func (*Factory) CreateClient ¶
CreateClient creates a new MongoDB client
func (*Factory) GetSupportedTypes ¶
func (f *Factory) GetSupportedTypes() []vectordb.VectorDBType
GetSupportedTypes returns the list of supported database types