main
HuangHai 4 weeks ago
parent 9e82dc00ce
commit a4ab3c2621

@ -23,6 +23,7 @@ mapping = {
"tags": { "tags": {
"type": "object", "type": "object",
"properties": { "properties": {
"tags": {"type": "keyword"},
"full_content": {"type": "text"} "full_content": {"type": "text"}
} }
} }

@ -15,7 +15,7 @@ es = Elasticsearch(
) )
# 2. 直接在代码中指定要查询的标签 # 2. 直接在代码中指定要查询的标签
query_tag = ["MATH_DATA_1", "小学数学"] # 可以修改为其他需要的标签 query_tag = ["MATH_DATA_1"] # 可以修改为其他需要的标签
# 3. 构建查询条件 # 3. 构建查询条件
query = { query = {
@ -23,17 +23,13 @@ query = {
"bool": { "bool": {
"should": [ "should": [
{ {
"match": { "terms": {
"tags": "MATH_DATA_1" "tags.tags": query_tag
}
},
{
"match": {
"tags": "小学数学"
} }
} }
], ],
"minimum_should_match": 1 "minimum_should_match": 1
} }
}, },
"size": 1000 "size": 1000

Loading…
Cancel
Save