## bool查询的使用
<br>
> must 各个条件都必须满足,即各条件是and的关系
```
GET /user/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"name": "李四"
}
},
{
"term": {
"address.keyword": "河北省"
}
}
]
}
}
}
```
> should 各个条件有一个满足即可,即各条件是or的关系
```
GET /user/_search
{
"query": {
"bool": {
"should": [
{
"match": {
"name": "李四"
}
},
{
"term": {
"address.keyword": "河北省"
}
}
]
}
}
}
```
> must_not 不满足所有条件,即各条件是not的关系
```
GET /user/_search
{
"query": {
"bool": {
"must_not": [
{
"match": {
"name": "李四"
}
},
{
"term": {
"address.keyword": "河北省"
}
}
]
}
}
}
```
> filter 不计算相关度评分,不计算_score即相关度评分,效率更高
```
GET /user/_search
{
"query": {
"bool": {
"filter": [
{
"term": {
"address.keyword": "河北省"
}
}
]
}
}
}
```