From 2a9597991f2df1c9974be0c2f9439e3f5d5dbe76 Mon Sep 17 00:00:00 2001 From: moon <2623532423@qq.com> Date: Tue, 16 Sep 2025 16:32:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=9B=E8=AE=B8bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/bjtds/brichat/entity/dataset/TDatasetFiles.java | 3 ++- .../brichat/service/impl/EsTDatasetFilesServiceImpl.java | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/chat-server/src/main/java/com/bjtds/brichat/entity/dataset/TDatasetFiles.java b/chat-server/src/main/java/com/bjtds/brichat/entity/dataset/TDatasetFiles.java index 6629cbc..242a4f2 100644 --- a/chat-server/src/main/java/com/bjtds/brichat/entity/dataset/TDatasetFiles.java +++ b/chat-server/src/main/java/com/bjtds/brichat/entity/dataset/TDatasetFiles.java @@ -25,10 +25,11 @@ public class TDatasetFiles { * 文件或文件夹名称 */ private String name; - + /** * 类型: file-文件, folder-文件夹 */ + private String type; /** diff --git a/chat-server/src/main/java/com/bjtds/brichat/service/impl/EsTDatasetFilesServiceImpl.java b/chat-server/src/main/java/com/bjtds/brichat/service/impl/EsTDatasetFilesServiceImpl.java index 14eb3ea..0cb95e1 100644 --- a/chat-server/src/main/java/com/bjtds/brichat/service/impl/EsTDatasetFilesServiceImpl.java +++ b/chat-server/src/main/java/com/bjtds/brichat/service/impl/EsTDatasetFilesServiceImpl.java @@ -5,7 +5,7 @@ import co.elastic.clients.elasticsearch.ElasticsearchClient; import co.elastic.clients.elasticsearch.core.SearchResponse; import co.elastic.clients.elasticsearch.core.search.Hit; import com.bjtds.brichat.entity.dataset.TDatasetFiles; - +import co.elastic.clients.elasticsearch._types.mapping.DynamicMapping; import com.bjtds.brichat.entity.dto.RecordDto; import com.bjtds.brichat.entity.dto.RetrievalDto; import com.bjtds.brichat.entity.esmodel.IndexInfo; @@ -54,6 +54,7 @@ public class EsTDatasetFilesServiceImpl implements EsTDatasetFilesService { client.indices().create(c -> c .index(DatasetId) .mappings(m -> m + .dynamic(DynamicMapping.False) .properties("name", p -> p.text(t -> t.analyzer("ik_max_word").searchAnalyzer("ik_max_word"))) .properties("content", p -> p.text(t -> t.analyzer("ik_max_word").searchAnalyzer("ik_max_word"))) .properties("dataset_id", p -> p.keyword(k -> k)) @@ -223,7 +224,7 @@ public class EsTDatasetFilesServiceImpl implements EsTDatasetFilesService { SearchResponse response = client.search(s -> s .index(DatasetId) .query(q -> q.bool(b -> b - .should(s1 -> s1.match(m -> m.field("title").query(keyword))) + .should(s1 -> s1.match(m -> m.field("name").query(keyword))) .should(s2 -> s2.match(m -> m.field("content").query(keyword))) )) .size(500)