HybridSearcher

org.llm4s.vectorstore.HybridSearcher
See theHybridSearcher companion class

Attributes

Companion
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

final case class Config(vectorStoreConfig: Config, keywordIndexConfig: Config, defaultStrategy: FusionStrategy)

Configuration for hybrid searcher.

Configuration for hybrid searcher.

Value parameters

defaultStrategy

Default fusion strategy

keywordIndexConfig

Keyword index configuration

vectorStoreConfig

Vector store configuration

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Config

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
Config.type

Value members

Concrete methods

def apply(vectorStore: VectorStore, keywordIndex: KeywordIndex, defaultStrategy: FusionStrategy): HybridSearcher

Create a hybrid searcher from existing stores.

Create a hybrid searcher from existing stores.

Value parameters

defaultStrategy

Default fusion strategy (default: RRF)

keywordIndex

Keyword index for BM25 search

vectorStore

Vector store for semantic search

Attributes

Returns

Hybrid searcher

Create a hybrid searcher from configuration.

Create a hybrid searcher from configuration.

Value parameters

config

Hybrid searcher configuration

Attributes

Returns

Hybrid searcher or error

Create a hybrid searcher with in-memory stores.

Create a hybrid searcher with in-memory stores.

Attributes

Returns

Hybrid searcher or error

def pgvector(vectorConfig: Config, keywordConfig: Config, defaultStrategy: FusionStrategy): Result[HybridSearcher]

Create a hybrid searcher with PostgreSQL backends using separate connection pools.

Create a hybrid searcher with PostgreSQL backends using separate connection pools.

Use this when you need independent pool management for vector and keyword stores. For most use cases, prefer pgvectorShared which shares a single pool.

Value parameters

defaultStrategy

Default fusion strategy

keywordConfig

Configuration for PgKeywordIndex

vectorConfig

Configuration for PgVectorStore

Attributes

Returns

Hybrid searcher or error

def pgvectorShared(connectionString: String, user: String, password: String, vectorTableName: String, keywordTableName: String, defaultStrategy: FusionStrategy): Result[HybridSearcher]

Create a hybrid searcher with PostgreSQL backends for both vector and keyword search.

Create a hybrid searcher with PostgreSQL backends for both vector and keyword search.

This enables fully PostgreSQL-based hybrid RAG using:

  • pgvector extension for vector similarity search
  • PostgreSQL native full-text search (tsvector/tsquery) for keyword search

Both stores share a connection pool for efficiency.

Requires PostgreSQL 16+ with pgvector extension installed. Recommended: PostgreSQL 18+ for best performance.

Value parameters

connectionString

JDBC connection string (e.g., "jdbc:postgresql://localhost:5432/mydb")

defaultStrategy

Default fusion strategy (default: RRF with k=60)

keywordTableName

Base table name for keywords (creates {tableName}_keyword table, default: "documents")

password

Database password

user

Database user

vectorTableName

Table name for vectors (default: "vectors")

Attributes

Returns

Hybrid searcher or error

def sqlite(vectorDbPath: String, keywordDbPath: String): Result[HybridSearcher]

Create a hybrid searcher with SQLite file-based stores.

Create a hybrid searcher with SQLite file-based stores.

Value parameters

keywordDbPath

Path to keyword index database

vectorDbPath

Path to vector store database

Attributes

Returns

Hybrid searcher or error