From a4ab3c26213a7441688c7aeac4a04a84be413977 Mon Sep 17 00:00:00 2001 From: HuangHai <10402852@qq.com> Date: Fri, 27 Jun 2025 11:57:45 +0800 Subject: [PATCH] 'commit' --- dsRag/ElasticSearch/T2_CreatingMapping.py | 1 + dsRag/ElasticSearch/T5_SelectByTags.py | 12 ++++-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/dsRag/ElasticSearch/T2_CreatingMapping.py b/dsRag/ElasticSearch/T2_CreatingMapping.py index dfbb824f..42f65b30 100644 --- a/dsRag/ElasticSearch/T2_CreatingMapping.py +++ b/dsRag/ElasticSearch/T2_CreatingMapping.py @@ -23,6 +23,7 @@ mapping = { "tags": { "type": "object", "properties": { + "tags": {"type": "keyword"}, "full_content": {"type": "text"} } } diff --git a/dsRag/ElasticSearch/T5_SelectByTags.py b/dsRag/ElasticSearch/T5_SelectByTags.py index 7e498c7f..24bd3fca 100644 --- a/dsRag/ElasticSearch/T5_SelectByTags.py +++ b/dsRag/ElasticSearch/T5_SelectByTags.py @@ -15,7 +15,7 @@ es = Elasticsearch( ) # 2. 直接在代码中指定要查询的标签 -query_tag = ["MATH_DATA_1", "小学数学"] # 可以修改为其他需要的标签 +query_tag = ["MATH_DATA_1"] # 可以修改为其他需要的标签 # 3. 构建查询条件 query = { @@ -23,17 +23,13 @@ query = { "bool": { "should": [ { - "match": { - "tags": "MATH_DATA_1" - } - }, - { - "match": { - "tags": "小学数学" + "terms": { + "tags.tags": query_tag } } ], "minimum_should_match": 1 + } }, "size": 1000