Skip to content

Vector Stores

Vector stores persist the embeddings and enable similarity search.

Available Stores

BackendTypeProsCons
GOBFile-basedSimple, no setupSingle machine only
PostgreSQLDatabaseScalable, team-friendlyRequires PostgreSQL + pgvector

GOB (File-based)

The default storage backend. Stores vectors in a binary file.

Configuration

store:
backend: gob
gob:
path: .grepai/index.gob

Characteristics

  • Pros:

    • Zero dependencies
    • Fast for small/medium codebases
    • Portable (just copy the file)
  • Cons:

    • Single machine only
    • Loads entire index into memory
    • No concurrent access

Best For

  • Personal projects
  • Quick experimentation
  • CI/CD pipelines (ephemeral index)

PostgreSQL with pgvector

Scalable vector storage using PostgreSQL and the pgvector extension.

Setup

  1. Install PostgreSQL with pgvector:
Terminal window
# macOS with Homebrew
brew install postgresql pgvector
# Ubuntu/Debian
sudo apt install postgresql postgresql-contrib
# Then install pgvector from source or package
  1. Create the database and extension:
CREATE DATABASE grepai;
\c grepai
CREATE EXTENSION vector;
  1. Create the table (auto-created by grepai, but for reference):
CREATE TABLE IF NOT EXISTS chunks (
id SERIAL PRIMARY KEY,
file_path TEXT NOT NULL,
start_line INT NOT NULL,
end_line INT NOT NULL,
content TEXT NOT NULL,
embedding vector(768), -- Adjust dimensions based on embedder
created_at TIMESTAMP DEFAULT NOW()
);
CREATE INDEX ON chunks USING ivfflat (embedding vector_cosine_ops);

Configuration

store:
backend: postgres
postgres:
connection_string: postgres://user:password@localhost:5432/grepai

Environment Variable

Terminal window
export GREPAI_POSTGRES_URL="postgres://user:password@localhost:5432/grepai"
store:
backend: postgres
postgres:
connection_string: ${GREPAI_POSTGRES_URL}

Characteristics

  • Pros:

    • Scales to large codebases
    • Concurrent access (team use)
    • Advanced filtering with SQL
    • Persistent and reliable
  • Cons:

    • Requires PostgreSQL setup
    • More complex deployment

Best For

  • Team environments
  • Large codebases (100k+ lines)
  • Production deployments
  • When you need SQL queries on metadata

Adding a New Store

To add a new storage backend:

  1. Implement the VectorStore interface in store/:
type VectorStore interface {
Store(ctx context.Context, chunks []Chunk) error
Search(ctx context.Context, embedding []float32, limit int) ([]Result, error)
Delete(ctx context.Context, filePath string) error
Close() error
}
  1. Add configuration in config/config.go

  2. Wire it up in the CLI commands

See Contributing for more details.