firestore

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, opts ...Option) (vectorstore.VectorStore, error)

New creates a new FirestoreVectorStore.

Options:

  • WithProjectID(id): Set GCP project ID (required)
  • WithCredentialsFile(path): Use service account credentials
  • Otherwise uses Application Default Credentials

Example:

store, err := firestore.New(ctx,
    WithProjectID("my-project"),
    WithCredentialsFile("/path/to/credentials.json"),
)

Types

type Config

type Config struct {
	ProjectID       string
	CredentialsFile string
}

Config contains configuration for the Firestore vector store.

type FirestoreCollection

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

FirestoreCollection represents a collection in Firestore.

func (*FirestoreCollection) Clear

func (c *FirestoreCollection) Clear(ctx context.Context) error

Clear removes all documents from the collection.

func (*FirestoreCollection) Count

func (c *FirestoreCollection) Count(ctx context.Context, filter vectorstore.Filter) (int64, error)

Count returns the number of documents in the collection.

func (*FirestoreCollection) Delete

Delete removes documents by their IDs.

func (*FirestoreCollection) DeleteByFilter

DeleteByFilter removes all documents matching the filter.

func (*FirestoreCollection) Get

Get retrieves documents by their IDs.

func (*FirestoreCollection) Name

func (c *FirestoreCollection) Name() string

Name returns the collection name.

func (*FirestoreCollection) Query

Query performs similarity search and returns matching documents.

func (*FirestoreCollection) QueryStream

QueryStream performs similarity search and streams results via an iterator.

func (*FirestoreCollection) Stats

Stats returns statistics about the collection.

func (*FirestoreCollection) Upsert

Upsert inserts or updates documents in the collection.

func (*FirestoreCollection) UpsertBatch

UpsertBatch performs batch upsert with progress tracking.

type FirestoreVectorStore

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

FirestoreVectorStore implements an in-production vector store using Google Cloud Firestore. It provides persistent, scalable vector storage with native TTL support.

Features:

  • Collection-based isolation
  • Native Firestore TTL for automatic expiration
  • BulkWriter for efficient batch operations
  • Composite indexes for Scope/Temporal fields
  • Content hash deduplication
  • Thread-safe operations
  • Streaming query support

Important Notes:

  • Firestore has a 500 operations per batch limit
  • Composite indexes must be created for filtered queries
  • Use FieldPath for safe metadata access
  • Collections map to Firestore collections (not subcollections)

func (*FirestoreVectorStore) Close

func (f *FirestoreVectorStore) Close() error

Close closes the connection to Firestore.

func (*FirestoreVectorStore) Collection

Collection returns a collection with the specified name and options.

func (*FirestoreVectorStore) DeleteCollection

func (f *FirestoreVectorStore) DeleteCollection(ctx context.Context, name string) error

DeleteCollection permanently deletes a collection and all its documents.

func (*FirestoreVectorStore) ListCollections

func (f *FirestoreVectorStore) ListCollections(ctx context.Context) ([]string, error)

ListCollections returns the names of all collections.

func (*FirestoreVectorStore) Stats

Stats returns statistics about the vector store.

type Option

type Option func(*Config)

Option configures a FirestoreVectorStore.

func WithCredentialsFile

func WithCredentialsFile(path string) Option

WithCredentialsFile sets the path to service account credentials.

func WithProjectID

func WithProjectID(projectID string) Option

WithProjectID sets the GCP project ID.

Jump to

Keyboard shortcuts

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