dsl
Elasticsearch provides a full Query DSL (Domain Specific Language) based on JSON to define queries. link (opens new window)
按 model 字段精确过滤
假设索引为 products,且 model.keyword 在 mapping 中是 keyword 字段:
GET products/_search
Content-Type: application/json
{
"query": {
"bool": {
"filter": [
{ "term": { "model.keyword": "example-model" } }
]
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
term 匹配索引中的精确项,不对查询文本做全文分析;filter 不参与相关性评分。如果 model 本身就是 keyword,直接使用 model,不能假定每个字段都有 .keyword 子字段。
全文搜索通常使用 match。执行前检查字段 mapping 与当前 Elasticsearch 版本。
上次更新: 2026/10/18, 22:14:48