orama icon indicating copy to clipboard operation
orama copied to clipboard

Plugin for the PgVector

Open saquib34 opened this issue 3 months ago • 2 comments

This pull request introduces a new @orama/plugin-pgvector package, enabling Orama to use PostgreSQL with the pgvector extension as a backend for persistent, memory-efficient vector search and storage. The implementation offloads document storage and vector operations to PostgreSQL, supports lazy loading and memory limits, and provides a test script for quick validation.

The most important changes are:

New Plugin Implementation:

  • Added the @orama/plugin-pgvector package with a package.json defining dependencies on pg, pgvector, TensorFlow libraries, and Orama, and including build/test scripts.
  • Implemented the main plugin logic in src/index.ts, which:
    • Hooks into Orama's lifecycle to store documents in PostgreSQL, remove them from memory, and perform vector searches directly in the database.
    • Supports lazy loading, memory limits, and a vector-search-only mode for efficiency.
    • Manages document caching and memory usage with an LRU strategy.

Database Management and Vector Operations:

  • Added src/pgvector-manager.ts to handle:
    • Table creation, schema adaptation, and vector column/index management in PostgreSQL.
    • Document insertion/removal, vector search queries, and memory cache management.
    • Efficient retrieval and reconstruction of documents with vector data.

Testing and Usage Example:

  • Provided a comprehensive test script test/quick-test.js that:
    • Sets up a test database, inserts sample documents with mock embeddings, and performs vector similarity searches.
    • Demonstrates plugin usage and verifies correct integration with Orama and PostgreSQL.

saquib34 avatar Sep 26 '25 06:09 saquib34

i have resolved GitHub CLI failed. I have added the test code that I missed

saquib34 avatar Oct 10 '25 20:10 saquib34

@micheleriva can you pls approve this workflow i have added the test file earlier which was failed

saquib34 avatar Nov 07 '25 16:11 saquib34