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
|
LEFT JOIN sys_user su ON vs.create_by = su.id
|
||||||
WHERE vs.project_id = #{projectId}
|
WHERE vs.project_id = #{projectId}
|
||||||
AND vs.deleted = 0
|
AND vs.deleted = 0
|
||||||
AND (vs.metadata->>'doc_id') IS NULL
|
AND vs.chunk_parent_id IS NULL
|
||||||
ORDER BY vs.create_time DESC
|
ORDER BY vs.create_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
<select id="selectChunkCount" resultType="java.lang.Integer">
|
<select id="selectChunkCount" resultType="java.lang.Integer">
|
||||||
SELECT COUNT(*)
|
SELECT COUNT(*)
|
||||||
FROM vector_store
|
FROM vector_store
|
||||||
WHERE metadata->>'doc_id' = #{docId}
|
WHERE chunk_parent_id = #{docId}
|
||||||
AND deleted = 0
|
AND deleted = 0
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -102,32 +102,32 @@
|
|||||||
<select id="selectDocumentChunks" resultType="cn.yinlihupo.domain.vo.DocumentChunkVO">
|
<select id="selectDocumentChunks" resultType="cn.yinlihupo.domain.vo.DocumentChunkVO">
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
id,
|
||||||
metadata->>'doc_id' as docId,
|
chunk_parent_id as docId,
|
||||||
content,
|
content,
|
||||||
CAST(metadata->>'chunk_index' AS INTEGER) as chunkIndex,
|
chunk_index as chunkIndex,
|
||||||
CAST(metadata->>'chunk_total' AS INTEGER) as chunkTotal,
|
chunk_total as chunkTotal,
|
||||||
metadata->>'title' as title,
|
title,
|
||||||
metadata->>'doc_type' as docType,
|
doc_type as docType,
|
||||||
metadata->>'source_type' as sourceType,
|
source_type as sourceType,
|
||||||
metadata->>'status' as status
|
status
|
||||||
FROM vector_store
|
FROM vector_store
|
||||||
WHERE metadata->>'doc_id' = #{docId}
|
WHERE chunk_parent_id = #{docId}
|
||||||
AND deleted = 0
|
AND deleted = 0
|
||||||
ORDER BY CAST(metadata->>'chunk_index' AS INTEGER)
|
ORDER BY chunk_index
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 查询分片详情 -->
|
<!-- 查询分片详情 -->
|
||||||
<select id="selectChunkById" resultType="cn.yinlihupo.domain.vo.DocumentChunkVO">
|
<select id="selectChunkById" resultType="cn.yinlihupo.domain.vo.DocumentChunkVO">
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
id,
|
||||||
metadata->>'doc_id' as docId,
|
chunk_parent_id as docId,
|
||||||
content,
|
content,
|
||||||
CAST(metadata->>'chunk_index' AS INTEGER) as chunkIndex,
|
chunk_index as chunkIndex,
|
||||||
CAST(metadata->>'chunk_total' AS INTEGER) as chunkTotal,
|
chunk_total as chunkTotal,
|
||||||
metadata->>'title' as title,
|
title,
|
||||||
metadata->>'doc_type' as docType,
|
doc_type as docType,
|
||||||
metadata->>'source_type' as sourceType,
|
source_type as sourceType,
|
||||||
metadata->>'status' as status
|
status
|
||||||
FROM vector_store
|
FROM vector_store
|
||||||
WHERE id = #{chunkId}
|
WHERE id = #{chunkId}
|
||||||
AND deleted = 0
|
AND deleted = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user