Plugin for the PgVector
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-pgvectorpackage with apackage.jsondefining dependencies onpg,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.tsto 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.jsthat:- 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.
i have resolved GitHub CLI failed. I have added the test code that I missed
@micheleriva can you pls approve this workflow i have added the test file earlier which was failed