neo4j

package
v0.9.21 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter wraps the Neo4j client to implement the vectordb.VectorDBClient interface

func (*Adapter) Close added in v0.8.1

func (a *Adapter) Close(ctx context.Context) error

Close closes the Neo4j adapter and cleans up resources

func (*Adapter) CollectionExists

func (a *Adapter) CollectionExists(ctx context.Context, name string) (bool, error)

CollectionExists checks if a collection exists

func (*Adapter) CreateCollection

func (a *Adapter) CreateCollection(ctx context.Context, name string, schema *vectordb.CollectionSchema) error

CreateCollection creates a new collection with the given schema

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

func (a *Adapter) DeleteCollection(ctx context.Context, name string) error

DeleteCollection deletes a collection and all its documents

func (*Adapter) DeleteDocument

func (a *Adapter) DeleteDocument(ctx context.Context, collectionName, documentID string) error

DeleteDocument deletes a document by ID

func (*Adapter) DeleteDocuments

func (a *Adapter) DeleteDocuments(ctx context.Context, collectionName string, documentIDs []string) error

DeleteDocuments deletes multiple documents by IDs

func (*Adapter) DeleteDocumentsByMetadata

func (a *Adapter) DeleteDocumentsByMetadata(ctx context.Context, collectionName string, metadata map[string]interface{}) error

DeleteDocumentsByMetadata deletes documents matching metadata criteria

func (*Adapter) GetCollectionCount

func (a *Adapter) GetCollectionCount(ctx context.Context, name string) (int64, error)

GetCollectionCount returns the number of documents in a collection

func (*Adapter) GetDefaultSchema

func (a *Adapter) GetDefaultSchema(schemaType vectordb.SchemaType, collectionName string) *vectordb.CollectionSchema

GetDefaultSchema returns a default schema for the given type

func (*Adapter) GetDocument

func (a *Adapter) GetDocument(ctx context.Context, collectionName, documentID string) (*vectordb.Document, error)

GetDocument retrieves a document by ID

func (*Adapter) GetSchema

func (a *Adapter) GetSchema(ctx context.Context, collectionName string) (*vectordb.CollectionSchema, error)

GetSchema retrieves the schema for a collection

func (*Adapter) Health

func (a *Adapter) Health(ctx context.Context) error

Health checks the health of the Neo4j instance

func (*Adapter) ListCollections

func (a *Adapter) ListCollections(ctx context.Context) ([]vectordb.CollectionInfo, error)

ListCollections returns a list of all collections

func (*Adapter) ListDocuments

func (a *Adapter) ListDocuments(ctx context.Context, collectionName string, limit int, offset int) ([]*vectordb.Document, error)

ListDocuments returns a list of documents in a collection

func (*Adapter) SearchBM25

func (a *Adapter) SearchBM25(ctx context.Context, collectionName, query string, options *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)

SearchBM25 performs keyword-based search using BM25 (not supported by Neo4j)

func (*Adapter) SearchByMetadata

func (a *Adapter) SearchByMetadata(ctx context.Context, collectionName string, metadata map[string]interface{}, options *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)

SearchByMetadata searches documents by metadata fields

func (*Adapter) SearchHybrid

func (a *Adapter) SearchHybrid(ctx context.Context, collectionName, query string, options *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)

SearchHybrid performs hybrid search (not supported by Neo4j)

func (*Adapter) SearchSemantic

func (a *Adapter) SearchSemantic(ctx context.Context, collectionName, query string, options *vectordb.QueryOptions) ([]*vectordb.QueryResult, error)

SearchSemantic performs semantic search using vector embeddings

func (*Adapter) UpdateDocument

func (a *Adapter) UpdateDocument(ctx context.Context, collectionName string, document *vectordb.Document) error

UpdateDocument updates an existing document

func (*Adapter) UpdateSchema

func (a *Adapter) UpdateSchema(ctx context.Context, collectionName string, schema *vectordb.CollectionSchema) error

UpdateSchema updates the schema for a collection (not fully supported)

func (*Adapter) ValidateSchema

func (a *Adapter) ValidateSchema(schema *vectordb.CollectionSchema) error

ValidateSchema validates a schema definition

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps the Neo4j driver to provide vector database operations

func NewClient

func NewClient(config *Config) (*Client, error)

NewClient creates a new Neo4j client

func (*Client) BatchCreateDocuments

func (c *Client) BatchCreateDocuments(ctx context.Context, collectionName string, docs []*Document) error

BatchCreateDocuments creates multiple documents in a single transaction

func (*Client) Close

func (c *Client) Close(ctx context.Context) error

Close closes the Neo4j driver

func (*Client) CollectionExists

func (c *Client) CollectionExists(ctx context.Context, name string) (bool, error)

CollectionExists checks if a vector index exists for the given collection name

func (*Client) CreateCollection

func (c *Client) CreateCollection(ctx context.Context, name string, dimensions int, similarity string) error

CreateCollection creates a new vector index for a node label In Neo4j, a "collection" maps to a node label with a vector index

func (*Client) CreateDocument

func (c *Client) CreateDocument(ctx context.Context, collectionName string, doc *Document) error

CreateDocument creates a new document node with vector embedding

func (*Client) DeleteAllDocuments

func (c *Client) DeleteAllDocuments(ctx context.Context, collectionName string) error

DeleteAllDocuments deletes all documents with the given label

func (*Client) DeleteCollection

func (c *Client) DeleteCollection(ctx context.Context, name string, deleteNodes bool) error

DeleteCollection deletes a vector index and optionally all nodes with the label

func (*Client) DeleteDocument

func (c *Client) DeleteDocument(ctx context.Context, collectionName, id string) error

DeleteDocument deletes a document by ID

func (*Client) DeleteDocuments

func (c *Client) DeleteDocuments(ctx context.Context, collectionName string, ids []string) error

DeleteDocuments deletes multiple documents by ID

func (*Client) GetCollectionCount

func (c *Client) GetCollectionCount(ctx context.Context, name string) (int64, error)

GetCollectionCount returns the number of nodes with the given label

func (*Client) GetCollectionInfo

func (c *Client) GetCollectionInfo(ctx context.Context, name string) (map[string]interface{}, error)

GetCollectionInfo returns metadata about a vector index

func (*Client) GetDocument

func (c *Client) GetDocument(ctx context.Context, collectionName, id string) (*Document, error)

GetDocument retrieves a document by ID

func (*Client) Health

func (c *Client) Health(ctx context.Context) error

Health checks the connection to Neo4j

func (*Client) ListCollections

func (c *Client) ListCollections(ctx context.Context) ([]string, error)

ListCollections returns all vector indexes (collections)

func (*Client) ListDocuments

func (c *Client) ListDocuments(ctx context.Context, collectionName string, limit int) ([]*Document, error)

ListDocuments returns all documents with the given label

func (*Client) UpdateDocument

func (c *Client) UpdateDocument(ctx context.Context, collectionName string, doc *Document) error

UpdateDocument updates an existing document

func (*Client) VectorSearch

func (c *Client) VectorSearch(ctx context.Context, collectionName string, vector []float32, limit int) ([]*QueryResult, error)

VectorSearch performs vector similarity search

func (*Client) VectorSearchWithFilter

func (c *Client) VectorSearchWithFilter(ctx context.Context, collectionName string, vector []float32, limit int, filter map[string]interface{}) ([]*QueryResult, error)

VectorSearchWithFilter performs vector similarity search with metadata filtering

type Config

type Config struct {
	// URI is the Neo4j connection URI (e.g., bolt://localhost:7687 or neo4j://localhost:7687)
	URI string

	// Username for authentication (default: neo4j)
	Username string

	// Password for authentication
	Password string

	// Database name (default: neo4j)
	Database string

	// MaxConnections for connection pool (default: 50)
	MaxConnections int

	// Timeout for operations (default: 30s)
	Timeout time.Duration

	// VectorDimensions for vector index (default: 1536)
	VectorDimensions int

	// SimilarityMetric for vector search (cosine or euclidean, default: cosine)
	SimilarityMetric string
}

Config represents the configuration for a Neo4j client

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a default Neo4j configuration

type Document

type Document struct {
	ID       string                 // Node ID property
	Content  string                 // Text content
	Vector   []float32              // Embedding vector
	Metadata map[string]interface{} // Additional properties
}

Document represents a document node in Neo4j

type Factory

type Factory struct {
	// contains filtered or unexported fields
}

Factory implements the vectordb.ClientFactory interface for Neo4j

func NewFactory

func NewFactory() *Factory

NewFactory creates a new Neo4j client factory

func (*Factory) CreateClient

func (f *Factory) CreateClient(config *vectordb.Config) (vectordb.VectorDBClient, error)

CreateClient creates a new Neo4j client from vectordb.Config

func (*Factory) GetSupportedTypes

func (f *Factory) GetSupportedTypes() []vectordb.VectorDBType

GetSupportedTypes returns the supported database types

func (*Factory) ValidateConfig

func (f *Factory) ValidateConfig(config *vectordb.Config) error

ValidateConfig validates the configuration

type QueryResult

type QueryResult struct {
	Document *Document
	Score    float64
}

QueryResult represents a vector search result

Jump to

Keyboard shortcuts

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