参考文档:https://es.xiaoleilu.com/010_Intro/30_Tutorial_Search.html
term:精确查询,不支持分词查询
match:like模糊匹配,支持分词查询
1、##term
GET /black/user/_search
{
"query": {
"term": {
"name": "black"
}
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/34fd76c5fa0f64ee8630db8d77420441.png)
2、##match
GET /black/user/_search
{
"from": 0,
"size": 2,
"query": {
"match": {
"car": "奔驰"
}
}
}
![](https://i-blog.csdnimg.cn/blog_migrate/30b42620d7e8794eac4b6fc04d71348e.png)
3、###使用filter过滤年龄
GET /black/user/_search
{
"query": {
"bool": {
"must": [{
"match_all": {}
}],
"filter": {
"range": {
"age": {
"gt": 21,
"lte": 51
}
}
}
}
},
"from": 0,
"size": 10,
"_source": ["name", "age"]
}
![](https://i-blog.csdnimg.cn/blog_migrate/9cc776d459a8fd1f736261c40fdeeb69.png)