Package sk.iway.iwcm.rag.vectorjpa
Interface EmbeddingChunkRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<EmbeddingChunkEntity,,Long> DomainIdRepository<EmbeddingChunkEntity,,Long> org.springframework.data.jpa.repository.JpaRepository<EmbeddingChunkEntity,,Long> org.springframework.data.jpa.repository.JpaSpecificationExecutor<EmbeddingChunkEntity>,org.springframework.data.repository.ListCrudRepository<EmbeddingChunkEntity,,Long> org.springframework.data.repository.ListPagingAndSortingRepository<EmbeddingChunkEntity,,Long> org.springframework.data.repository.PagingAndSortingRepository<EmbeddingChunkEntity,,Long> org.springframework.data.repository.query.QueryByExampleExecutor<EmbeddingChunkEntity>,org.springframework.data.repository.Repository<EmbeddingChunkEntity,Long>
@Repository
public interface EmbeddingChunkRepository
extends DomainIdRepository<EmbeddingChunkEntity,Long>
Spring Data repository for
EmbeddingChunkEntity.
Provides JPA query methods for managing embedding chunks in the rag_embedding_chunks table.
Note: the actual embedding vector storage is managed via native SQL through
VectorStore.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.data.jpa.repository.JpaSpecificationExecutor
org.springframework.data.jpa.repository.JpaSpecificationExecutor.SpecificationFluentQuery<T extends Object> -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteByEntityTypeAndEntityIdAndDomainId(RagEntityType entityType, Long entityId, Integer domainId) Deletes all chunks for a source in one storage domain, regardless of provider or model.voiddeleteByEntityTypeAndEntityIdAndEmbeddingProviderAndEmbeddingModelAndDomainId(RagEntityType entityType, Long entityId, String embeddingProvider, String embeddingModel, Integer domainId) Deletes only the selected provider and model's chunks for a source in one storage domain.findByEntityTypeAndDomainIdAndSourcePathStartingWith(RagEntityType entityType, Integer domainId, String sourcePath) findByEntityTypeAndEntityIdAndDomainId(RagEntityType entityType, Long entityId, Integer domainId) Finds documents whose stored chunks lack one or more group-scope values across all domains.findDistinctEntityIdsByEntityTypeAndDomainId(RagEntityType entityType, Integer domainId) Lists distinct source IDs for document queue operations in one storage domain.findDistinctEntityIdsByEntityTypeAndEmbeddingProviderAndEmbeddingModelAndDomainId(RagEntityType entityType, String embeddingProvider, String embeddingModel, Integer domainId) Lists source IDs with stored chunks from the selected provider and model.findDistinctEntityTypes(Integer domainId) Lists source types with stored chunks in the specified storage domain.intupdateDocumentGroupData(Long entityId, Integer groupId, Integer rootGroupL1, Integer rootGroupL2, Integer rootGroupL3) Updates group-scope metadata on all chunks of a document across providers, models, and domains.Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, saveMethods inherited from interface sk.iway.iwcm.system.datatable.spring.DomainIdRepository
findAllByDomainId, findAllByDomainId, findAllByIdInAndDomainId, findFirstByIdAndDomainIdMethods inherited from interface org.springframework.data.jpa.repository.JpaRepository
deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlushMethods inherited from interface org.springframework.data.jpa.repository.JpaSpecificationExecutor
count, count, delete, delete, exists, exists, findAll, findAll, findAll, findAll, findAll, findBy, findBy, findOne, findOne, updateMethods inherited from interface org.springframework.data.repository.ListCrudRepository
findAll, findAllById, saveAllMethods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.PagingAndSortingRepository
findAllMethods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor
count, exists, findAll, findBy, findOne
-
Method Details
-
findByEntityTypeAndDomainIdAndSourcePathStartingWith
List<EmbeddingChunkEntity> findByEntityTypeAndDomainIdAndSourcePathStartingWith(RagEntityType entityType, Integer domainId, String sourcePath) -
findByEntityTypeAndEntityIdAndDomainId
List<EmbeddingChunkEntity> findByEntityTypeAndEntityIdAndDomainId(RagEntityType entityType, Long entityId, Integer domainId) -
deleteByEntityTypeAndEntityIdAndDomainId
@Transactional @Modifying @Query("DELETE FROM EmbeddingChunkEntity c WHERE c.entityType = :entityType AND c.entityId = :entityId AND c.domainId = :domainId") void deleteByEntityTypeAndEntityIdAndDomainId(@Param("entityType") RagEntityType entityType, @Param("entityId") Long entityId, @Param("domainId") Integer domainId) Deletes all chunks for a source in one storage domain, regardless of provider or model.- Parameters:
entityType- source entity typeentityId- source identifierdomainId- storage domain, including zero for shared Markdown
-
deleteByEntityTypeAndEntityIdAndEmbeddingProviderAndEmbeddingModelAndDomainId
@Transactional @Modifying @Query("DELETE FROM EmbeddingChunkEntity c WHERE c.entityType = :entityType AND c.entityId = :entityId AND c.embeddingProvider = :embeddingProvider AND c.embeddingModel = :embeddingModel AND c.domainId = :domainId") void deleteByEntityTypeAndEntityIdAndEmbeddingProviderAndEmbeddingModelAndDomainId(@Param("entityType") RagEntityType entityType, @Param("entityId") Long entityId, @Param("embeddingProvider") String embeddingProvider, @Param("embeddingModel") String embeddingModel, @Param("domainId") Integer domainId) Deletes only the selected provider and model's chunks for a source in one storage domain.- Parameters:
entityType- source entity typeentityId- source identifierembeddingProvider- provider that generated the chunksembeddingModel- model that generated the chunksdomainId- storage domain, including zero for shared Markdown
-
findDistinctEntityTypes
@Query("SELECT DISTINCT c.entityType FROM EmbeddingChunkEntity c WHERE c.domainId = :domainId") List<RagEntityType> findDistinctEntityTypes(@Param("domainId") Integer domainId) Lists source types with stored chunks in the specified storage domain.- Parameters:
domainId- storage domain, including zero for shared Markdown- Returns:
- distinct stored entity types
-
findDistinctEntityIdsByEntityTypeAndDomainId
@Query("SELECT DISTINCT c.entityId FROM EmbeddingChunkEntity c WHERE c.entityType = :entityType AND c.domainId = :domainId") List<Integer> findDistinctEntityIdsByEntityTypeAndDomainId(RagEntityType entityType, Integer domainId) Lists distinct source IDs for document queue operations in one storage domain. The integer return type is intended for document IDs, not Markdown long identifiers.- Parameters:
entityType- source entity type, normallyDOCUMENTdomainId- storage domain- Returns:
- distinct source IDs represented as integers
-
findDistinctEntityIdsByEntityTypeAndEmbeddingProviderAndEmbeddingModelAndDomainId
@Query("SELECT DISTINCT c.entityId FROM EmbeddingChunkEntity c WHERE c.entityType = :entityType AND c.embeddingProvider = :embeddingProvider AND c.embeddingModel = :embeddingModel AND c.domainId = :domainId") List<Integer> findDistinctEntityIdsByEntityTypeAndEmbeddingProviderAndEmbeddingModelAndDomainId(@Param("entityType") RagEntityType entityType, @Param("embeddingProvider") String embeddingProvider, @Param("embeddingModel") String embeddingModel, @Param("domainId") Integer domainId) Lists source IDs with stored chunks from the selected provider and model. The integer return type is intended for document IDs, not Markdown long identifiers.- Parameters:
entityType- source entity type, normallyDOCUMENTembeddingProvider- provider that generated the chunksembeddingModel- model that generated the chunksdomainId- storage domain- Returns:
- distinct source IDs represented as integers
-
findDistinctDocumentEntityIdsWithIncompleteGroupData
@Query("SELECT DISTINCT c.entityId FROM EmbeddingChunkEntity c WHERE c.entityType = sk.iway.iwcm.rag.service.RagEntityType.DOCUMENT AND (c.groupId IS NULL OR c.rootGroupL1 IS NULL OR c.rootGroupL2 IS NULL OR c.rootGroupL3 IS NULL)") List<Long> findDistinctDocumentEntityIdsWithIncompleteGroupData()Finds documents whose stored chunks lack one or more group-scope values across all domains.- Returns:
- distinct document IDs requiring group metadata backfill
-
updateDocumentGroupData
@Transactional @Modifying @Query("UPDATE EmbeddingChunkEntity c SET c.groupId = :groupId, c.rootGroupL1 = :rootGroupL1, c.rootGroupL2 = :rootGroupL2, c.rootGroupL3 = :rootGroupL3 WHERE c.entityType = sk.iway.iwcm.rag.service.RagEntityType.DOCUMENT AND c.entityId = :entityId") int updateDocumentGroupData(@Param("entityId") Long entityId, @Param("groupId") Integer groupId, @Param("rootGroupL1") Integer rootGroupL1, @Param("rootGroupL2") Integer rootGroupL2, @Param("rootGroupL3") Integer rootGroupL3) Updates group-scope metadata on all chunks of a document across providers, models, and domains.- Parameters:
entityId- document IDgroupId- immediate document group IDrootGroupL1- first-level root group IDrootGroupL2- second-level root group IDrootGroupL3- third-level root group ID- Returns:
- number of chunk rows updated
-