PostgreSQL implementation of SearchIndex with permission-based filtering.
Uses HikariCP for connection pooling and pgvector for efficient vector similarity search.
The implementation:
- Extends the vectors table with collection_id and readable_by columns
- Uses GIN indexes for efficient array containment queries
- Applies two-level permission filtering (collection + document)
- Gracefully handles corrupt embeddings without failing queries
Corrupt Embedding Handling:
- Records with unparseable embeddings are skipped during query operations
- Corrupt records are logged with id and embedding_dim for debugging
- Queries continue successfully and return topK valid results
- No silent data corruption - failures are observable via logs
Value parameters
- dataSource
-
HikariCP data source for connection pooling
- vectorTableName
-
Name of the vectors table
Attributes
- Companion
- object
- Graph
-
- Supertypes
Members list
Value members
Concrete methods
Delete all documents in a collection.
Delete all documents in a collection.
Does not delete the collection itself.
Value parameters
- collectionPath
-
The collection to clear
Attributes
- Returns
-
Number of chunks deleted
- Definition Classes
Close the search index and release resources.
Access to collection management
Delete a document from a collection.
Delete a document from a collection.
Removes all chunks associated with the document.
Value parameters
- collectionPath
-
The collection containing the document
- documentId
-
The document identifier
Attributes
- Returns
-
Number of chunks deleted
- Definition Classes
Drop the permission schema.
Drop the permission schema.
WARNING: This is destructive and will delete all permission data. Only use for testing or complete reset.
Attributes
- Returns
-
Success or error
- Definition Classes
Ingest a document into a specific collection.
Ingest a document into a specific collection.
The collection must:
- Exist (call ensureExists first if needed)
- Be a leaf collection (can contain documents)
Value parameters
- chunks
-
Pre-chunked content with embeddings
- collectionPath
-
Target collection path
- documentId
-
Unique document identifier
- metadata
-
Document metadata
- readableBy
-
Document-level permission override (empty = inherit from collection)
Attributes
- Returns
-
Number of chunks indexed
- Definition Classes
Initialize the permission schema.
Initialize the permission schema.
Creates necessary tables and indexes if they don't exist. Safe to call multiple times (idempotent).
Attributes
- Returns
-
Success or error
- Definition Classes
Expose PostgreSQL configuration for automatic RAG integration
Expose PostgreSQL configuration for automatic RAG integration
Attributes
- Definition Classes
Access to principal (user/group) management
Query for the most similar vectors matching the user's permissions.
Query for the most similar vectors matching the user's permissions.
Note: if the database contains corrupt embeddings, those rows are silently skipped. Because filtering happens after the SQL LIMIT topK, fewer than topK results may be returned when corrupt rows are present.
Attributes
- Definition Classes
Inherited methods
Query with a text query (for hybrid search).
Query with a text query (for hybrid search).
Value parameters
- additionalFilter
-
Optional additional metadata filter
- auth
-
User authorization context
- collectionPattern
-
Pattern to filter collections
- queryText
-
Text for keyword search (optional)
- queryVector
-
Embedding vector for semantic search
- topK
-
Maximum number of results
Attributes
- Returns
-
Permission-filtered search results
- Inherited from:
- SearchIndex
Get statistics for a collection.
Get statistics for a collection.
Value parameters
- collectionPath
-
The collection path
Attributes
- Returns
-
Collection statistics
- Inherited from:
- SearchIndex