ESmust、filter、should⼀起使⽤,导致的should语句失效当使⽤should查询时,如果包含了must或者filter查询,那么should的查询语句就不是或者【OR】的意思了,⽽是有或者没有都⾏的含义。
filter和should语句组合查询,会导致should语句失效
GET zx_album/album/_arch
{
"query": {
"bool": {毕节百里杜鹃
"filter": [
{立即的近义词
"term": {
"urId": {
"value": "115102970493227008",
"boost": 1
}
}
},
{
"term": {
"status": {
"value": "0",
"boost": 1
}
}
留学文书写作
}
],
"should": [
{
"term": {
"moveType": {
幼儿园寒假计划表
"value": 7,
"boost": 1
}
}
},
{
"term": {
"moveType": {
"value": 2,
"boost": 1
}
}
}
],
"disable_coord": fal,
"adjust_pure_negative": true,
"boost": 1月子餐食谱大全
}
}
}
中期检查查询的数据不对,因为should没有被正确执⾏。
解决⽅案⼀:加上"minimum_number_should_match": 1 这个设置should语句的满⾜条件值。
解决⽅案⼆:将should嵌在must语句中。
GET zx_album/album/_arch {"query": {
"bool" : {
"filter" : [
{
"term" : {
"urId" : {
"value" : "115102970493227008" }
}
},
{
"term" : {
"status" : {
"value" : "0"
}
}
},
感激遇到你{
"bool" : {
"should" : [
{
"term" : {
"moveType" : {
"value" : 7
}
}
},
{
"term" : {
"moveType" : {
"value" : 2
}
}
}
]
}
}
]
椒盐猪手的做法}}
}
must语句和filter⼀样的做法