fix(db): 修复分片查询中字段引用错误
- 将多处 metadata JSON 字段访问替换为对应的数据库列(chunk_parent_id等) - 修正 select 语句中的排序字段,避免类型转换错误 - 优化分片计数和详情查询的条件及字段映射 - 保证查询逻辑符合当前数据库表结构,提升查询性能和准确性
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
LEFT JOIN sys_user su ON vs.create_by = su.id
|
||||
WHERE vs.project_id = #{projectId}
|
||||
AND vs.deleted = 0
|
||||
AND (vs.metadata->>'doc_id') IS NULL
|
||||
AND vs.chunk_parent_id IS NULL
|
||||
ORDER BY vs.create_time DESC
|
||||
</select>
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
<select id="selectChunkCount" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*)
|
||||
FROM vector_store
|
||||
WHERE metadata->>'doc_id' = #{docId}
|
||||
WHERE chunk_parent_id = #{docId}
|
||||
AND deleted = 0
|
||||
</select>
|
||||
|
||||
@@ -102,32 +102,32 @@
|
||||
<select id="selectDocumentChunks" resultType="cn.yinlihupo.domain.vo.DocumentChunkVO">
|
||||
SELECT
|
||||
id,
|
||||
metadata->>'doc_id' as docId,
|
||||
chunk_parent_id as docId,
|
||||
content,
|
||||
CAST(metadata->>'chunk_index' AS INTEGER) as chunkIndex,
|
||||
CAST(metadata->>'chunk_total' AS INTEGER) as chunkTotal,
|
||||
metadata->>'title' as title,
|
||||
metadata->>'doc_type' as docType,
|
||||
metadata->>'source_type' as sourceType,
|
||||
metadata->>'status' as status
|
||||
chunk_index as chunkIndex,
|
||||
chunk_total as chunkTotal,
|
||||
title,
|
||||
doc_type as docType,
|
||||
source_type as sourceType,
|
||||
status
|
||||
FROM vector_store
|
||||
WHERE metadata->>'doc_id' = #{docId}
|
||||
WHERE chunk_parent_id = #{docId}
|
||||
AND deleted = 0
|
||||
ORDER BY CAST(metadata->>'chunk_index' AS INTEGER)
|
||||
ORDER BY chunk_index
|
||||
</select>
|
||||
|
||||
<!-- 查询分片详情 -->
|
||||
<select id="selectChunkById" resultType="cn.yinlihupo.domain.vo.DocumentChunkVO">
|
||||
SELECT
|
||||
id,
|
||||
metadata->>'doc_id' as docId,
|
||||
chunk_parent_id as docId,
|
||||
content,
|
||||
CAST(metadata->>'chunk_index' AS INTEGER) as chunkIndex,
|
||||
CAST(metadata->>'chunk_total' AS INTEGER) as chunkTotal,
|
||||
metadata->>'title' as title,
|
||||
metadata->>'doc_type' as docType,
|
||||
metadata->>'source_type' as sourceType,
|
||||
metadata->>'status' as status
|
||||
chunk_index as chunkIndex,
|
||||
chunk_total as chunkTotal,
|
||||
title,
|
||||
doc_type as docType,
|
||||
source_type as sourceType,
|
||||
status
|
||||
FROM vector_store
|
||||
WHERE id = #{chunkId}
|
||||
AND deleted = 0
|
||||
|
||||
Reference in New Issue
Block a user