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)