Package sk.iway.iwcm.rag.vectorstore
Class VectorStoreRouter
java.lang.Object
sk.iway.iwcm.rag.vectorstore.VectorStoreRouter
- All Implemented Interfaces:
VectorStore
Routes vector operations to the implementation matching the selected RAG datasource.
-
Constructor Summary
ConstructorsConstructorDescriptionVectorStoreRouter(PgVectorStore pgVectorStore, MariaDbVectorStore mariaDbVectorStore) -
Method Summary
Modifier and TypeMethodDescriptiongetExistingEmbeddingsByHash(String entityType, long entityId, String embeddingProvider, String embeddingModel, int domainId) Get existing embeddings for an entity and domain, keyed by content hash.booleanInitialize the database-specific vector schema if needed.booleanCheck if the vector store can be used in the current runtime configuration.booleanCheck if the vector store is available and schema is initialized.booleanRecreate the database-specific vector index using the configured metric.booleanresetDimensions(int dimensions) Delete all stored embeddings and resize the vector column.search(float[] queryEmbedding, String embeddingProvider, String embeddingModel, RagEntityType entityType, Integer domainId, String language, int limit, Map<String, Object> bonusParams) Find the most similar chunks to the query embedding.searchFulltext(String query, String embeddingProvider, String embeddingModel, RagEntityType entityType, Integer domainId, String language, int limit, Map<String, Object> bonusParams) Find relevant chunks by fulltext search in chunk text.voidupdateEmbedding(Long id, float[] embedding) Update the embedding vector for an existing chunk entity.voidupdateEmbeddingBatch(List<Long> ids, List<float[]> embeddings) Update embedding vectors for multiple existing chunk entities in a batch.
-
Constructor Details
-
VectorStoreRouter
-
-
Method Details
-
updateEmbedding
Description copied from interface:VectorStoreUpdate the embedding vector for an existing chunk entity. The entity must already be saved via EmbeddingChunkRepository.- Specified by:
updateEmbeddingin interfaceVectorStore- Parameters:
id- the chunk entity IDembedding- the embedding vector
-
updateEmbeddingBatch
Description copied from interface:VectorStoreUpdate embedding vectors for multiple existing chunk entities in a batch. All entities must already be saved via EmbeddingChunkRepository.- Specified by:
updateEmbeddingBatchin interfaceVectorStore- Parameters:
ids- the chunk entity IDsembeddings- the embedding vectors (must match ids in size and order)
-
search
public List<VectorSearchResult> search(float[] queryEmbedding, String embeddingProvider, String embeddingModel, RagEntityType entityType, Integer domainId, String language, int limit, Map<String, Object> bonusParams) Description copied from interface:VectorStoreFind the most similar chunks to the query embedding.- Specified by:
searchin interfaceVectorStore- Parameters:
queryEmbedding- the query vectorembeddingProvider- provider used to generate/query embeddingsembeddingModel- model used to generate/query embeddingsentityType- entity type to filter by (null for all)domainId- domain ID to filter by (null for all)language- language to filter by (null for all)limit- max number of resultsbonusParams- optional store-specific filters, such as document root groups- Returns:
- list of search results ordered by similarity (descending)
-
searchFulltext
public List<VectorSearchResult> searchFulltext(String query, String embeddingProvider, String embeddingModel, RagEntityType entityType, Integer domainId, String language, int limit, Map<String, Object> bonusParams) Description copied from interface:VectorStoreFind relevant chunks by fulltext search in chunk text.- Specified by:
searchFulltextin interfaceVectorStore- Parameters:
query- textual queryembeddingProvider- provider used to filter rowsembeddingModel- model used to filter rowsentityType- entity type to filter by (null for all)domainId- domain ID to filter by (null for all)language- language to filter by (null for all)limit- max number of resultsbonusParams- optional store-specific filters, such as document root groups and fallback flags- Returns:
- list of search results ordered by fulltext rank (descending)
-
isAvailable
public boolean isAvailable()Description copied from interface:VectorStoreCheck if the vector store can be used in the current runtime configuration. This does not guarantee that required schema objects already exist.- Specified by:
isAvailablein interfaceVectorStore
-
isAvailableAndInitialized
public boolean isAvailableAndInitialized()Description copied from interface:VectorStoreCheck if the vector store is available and schema is initialized. Implementations should return true only when operations can be executed safely.- Specified by:
isAvailableAndInitializedin interfaceVectorStore
-
initializeSchema
public boolean initializeSchema()Description copied from interface:VectorStoreInitialize the database-specific vector schema if needed.- Specified by:
initializeSchemain interfaceVectorStore
-
recreateIndex
public boolean recreateIndex()Description copied from interface:VectorStoreRecreate the database-specific vector index using the configured metric. Implementations without a native index-management capability may keep the default.- Specified by:
recreateIndexin interfaceVectorStore- Returns:
- true when the index was recreated successfully
-
resetDimensions
public boolean resetDimensions(int dimensions) Description copied from interface:VectorStoreDelete all stored embeddings and resize the vector column.- Specified by:
resetDimensionsin interfaceVectorStore- Parameters:
dimensions- new vector dimensions
-
getExistingEmbeddingsByHash
public Map<String,float[]> getExistingEmbeddingsByHash(String entityType, long entityId, String embeddingProvider, String embeddingModel, int domainId) Description copied from interface:VectorStoreGet existing embeddings for an entity and domain, keyed by content hash. Used to skip re-embedding unchanged chunks.- Specified by:
getExistingEmbeddingsByHashin interfaceVectorStore- Parameters:
entityType- entity type of the indexed objectentityId- ID of the indexed objectembeddingProvider- provider that generated the embeddingsembeddingModel- model that generated the embeddingsdomainId- domain that owns the indexed object- Returns:
- existing embeddings keyed by content hash
-