PostgreSQL-based keyword index implementation using native full-text search.
Uses PostgreSQL's tsvector/tsquery for efficient text indexing and ranking. Provides BM25-like scoring via ts_rank_cd (cover density ranking).
Requirements:
- PostgreSQL 16+ (18+ recommended for best performance)
Features:
- Native PostgreSQL full-text search with tsvector
- ts_rank_cd scoring for relevance ranking
- ts_headline for snippet highlighting
- GIN indexing for fast full-text lookups
- JSONB metadata storage with GIN index
- Connection pooling via HikariCP
Query syntax (via websearch_to_tsquery):
- "hello world" - documents containing both terms
- "hello OR world" - documents containing either term
- "-hello" - exclude documents with hello
- ""hello world"" - exact phrase match
Value parameters
- dataSource
-
HikariCP data source for connection pooling
- language
-
PostgreSQL text search configuration (default: "english")
- ownsDataSource
-
Whether to close dataSource on close()
- tableName
-
Base table name (creates {tableName}_keyword table)
Attributes
- Companion
- object
- Graph
-
- Supertypes
Members list
Value members
Concrete methods
Clear all indexed documents.
Clear all indexed documents.
Attributes
- Returns
-
Unit on success, or error
- Definition Classes
Close the index and release resources.
Count total indexed documents.
Delete a document by ID.
Delete a document by ID.
Value parameters
- id
-
Document ID
Attributes
- Returns
-
Unit on success, or error
- Definition Classes
Delete multiple documents.
Delete multiple documents.
Value parameters
- ids
-
Document IDs to delete
Attributes
- Returns
-
Unit on success, or error
- Definition Classes
Delete all documents with IDs starting with the given prefix.
Delete all documents with IDs starting with the given prefix.
Value parameters
- prefix
-
The ID prefix to match
Attributes
- Returns
-
Number of documents deleted
- Definition Classes
Get a document by ID.
Get a document by ID.
Value parameters
- id
-
Document ID
Attributes
- Returns
-
Document if found, None if not found, or error
- Definition Classes
Index a single document.
Index a single document.
Value parameters
- doc
-
Document to index
Attributes
- Returns
-
Unit on success, or error
- Definition Classes
Index multiple documents in batch.
Index multiple documents in batch.
Value parameters
- docs
-
Documents to index
Attributes
- Returns
-
Unit on success, or error
- Definition Classes
Search for documents matching a query.
Search for documents matching a query.
Uses BM25 scoring for relevance ranking.
Value parameters
- filter
-
Optional metadata filter
- query
-
Search query (supports operators depending on implementation)
- topK
-
Maximum number of results to return
Attributes
- Returns
-
Ranked search results, or error
- Definition Classes
Search with highlighted snippets.
Search with highlighted snippets.
Value parameters
- filter
-
Optional metadata filter
- query
-
Search query
- snippetLength
-
Target length for highlight snippets
- topK
-
Maximum number of results
Attributes
- Returns
-
Results with highlighted matches
- Definition Classes
Get index statistics.
Inherited methods
Update a document (re-index with new content).
Update a document (re-index with new content).
Value parameters
- doc
-
Updated document
Attributes
- Returns
-
Unit on success, or error
- Inherited from:
- KeywordIndex