修改了es的构建索引的内容的id,修复文档少的went

This commit is contained in:
moon 2025-09-25 16:22:13 +08:00
parent 7a61745cbf
commit 8a357008a3
4 changed files with 9 additions and 6 deletions

View File

@ -108,9 +108,9 @@ export const deleteDataset = (id: string) => {
} }
interface RenameParams { interface RenameParams {
fileId: number fileId: number
newName: string newName: string
} }
export const renameDocument = (data: RenameParams) => { export const renameDocument = (data: RenameParams) => {
return request({ return request({
url: '/brichat-service/datasetManage/document/rename', url: '/brichat-service/datasetManage/document/rename',

View File

@ -133,7 +133,7 @@ public class EsTDatasetFilesServiceImpl implements EsTDatasetFilesService {
try { try {
client.index(req -> req client.index(req -> req
.index(subDoc.getDifyDatasetId()) .index(subDoc.getDifyDatasetId())
.id(subDoc.getId().toString()) .id(subDoc.getId() + "_" + UUID.randomUUID())
.document(subDoc) .document(subDoc)
); );
log.info("异步添加文档分片到索引 fileId={} docName={}", subDoc.getId(), subDoc.getName()); log.info("异步添加文档分片到索引 fileId={} docName={}", subDoc.getId(), subDoc.getName());
@ -175,7 +175,7 @@ public class EsTDatasetFilesServiceImpl implements EsTDatasetFilesService {
client.index(req -> req client.index(req -> req
.index(singleDoc.getDifyDatasetId()) .index(singleDoc.getDifyDatasetId())
.id(singleDoc.getId().toString()) .id(singleDoc.getId() + "_" + UUID.randomUUID())
.document(singleDoc) .document(singleDoc)
); );
log.info("Single文档索引成功 fileId={} docName={}", singleDoc.getId(), singleDoc.getName()); log.info("Single文档索引成功 fileId={} docName={}", singleDoc.getId(), singleDoc.getName());

View File

@ -14,6 +14,7 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
@ -76,11 +77,12 @@ public class EsTDatasetFilesImporter {
} }
File file = new File(filePath); File file = new File(filePath);
if (!file.exists()) { if (!file.exists()) {
log.error(file.getAbsolutePath() + " 不存在,跳过"); log.error("文件不存在: {}", file.getAbsolutePath());
failed_2++; failed_2++;
redisTemplate.opsForValue().set("import:task:" + taskId + ":failed2", String.valueOf(failed_2)); redisTemplate.opsForValue().set("import:task:" + taskId + ":failed2", String.valueOf(failed_2));
continue; continue;
} }
if(Boolean.TRUE.equals(document.getIsEs())){ if(Boolean.TRUE.equals(document.getIsEs())){
log.warn("documentId=" + document.getId() + " 是ES索引文件跳过"); log.warn("documentId=" + document.getId() + " 是ES索引文件跳过");
failed_3++; failed_3++;

View File

@ -261,6 +261,7 @@
SELECT <include refid="Base_Column_List"/> SELECT <include refid="Base_Column_List"/>
FROM t_dataset_files FROM t_dataset_files
WHERE type = 'file' WHERE type = 'file'
and indexing_status='completed'
ORDER BY created_at DESC ORDER BY created_at DESC
</select> </select>