SQLiteKeywordIndex

org.llm4s.vectorstore.SQLiteKeywordIndex
See theSQLiteKeywordIndex companion object
final class SQLiteKeywordIndex extends KeywordIndex

SQLite FTS5-based keyword index implementation.

Uses SQLite's Full-Text Search 5 extension with BM25 scoring. FTS5 provides efficient text indexing and ranking capabilities.

Features:

  • BM25 relevance scoring
  • Snippet highlighting
  • Boolean query operators (AND, OR, NOT)
  • Phrase matching with quotes
  • Prefix matching with *

Query syntax examples:

  • "hello world" - documents containing both terms
  • "hello OR world" - documents containing either term
  • "hello NOT world" - documents with hello but not world
  • ""hello world"" - exact phrase match
  • "hello*" - prefix match

Attributes

Companion
object
Graph
Supertypes
trait KeywordIndex
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

override def clear(): Result[Unit]

Clear all indexed documents.

Clear all indexed documents.

Attributes

Returns

Unit on success, or error

Definition Classes
override def close(): Unit

Close the index and release resources.

Close the index and release resources.

Attributes

Definition Classes
override def count(): Result[Long]

Count total indexed documents.

Count total indexed documents.

Attributes

Returns

Document count

Definition Classes
override def delete(id: String): Result[Unit]

Delete a document by ID.

Delete a document by ID.

Value parameters

id

Document ID

Attributes

Returns

Unit on success, or error

Definition Classes
override def deleteBatch(ids: Seq[String]): Result[Unit]

Delete multiple documents.

Delete multiple documents.

Value parameters

ids

Document IDs to delete

Attributes

Returns

Unit on success, or error

Definition Classes
override def deleteByPrefix(prefix: String): Result[Long]

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
override def get(id: String): Result[Option[KeywordDocument]]

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
override def index(doc: KeywordDocument): Result[Unit]

Index a single document.

Index a single document.

Value parameters

doc

Document to index

Attributes

Returns

Unit on success, or error

Definition Classes
override def indexBatch(docs: Seq[KeywordDocument]): Result[Unit]

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
override def search(query: String, topK: Int, filter: Option[MetadataFilter]): Result[Seq[KeywordSearchResult]]

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
override def searchWithHighlights(query: String, topK: Int, snippetLength: Int, filter: Option[MetadataFilter]): Result[Seq[KeywordSearchResult]]

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
override def stats(): Result[KeywordIndexStats]

Get index statistics.

Get index statistics.

Attributes

Returns

Index statistics

Definition Classes

Inherited methods

def update(doc: KeywordDocument): Result[Unit]

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

Concrete fields

val tableName: String