{
“query”: {
“bool”: {
“must_not”: [
{
“term”: {
“item_type”: 4
}
},
{
“term”: {
“can_see”: true
}
}
],
“should”: [
{
“regexp”: {
“item_no”: “.?2602.?”
}
},
{
“regexp”: {
“description”: “.?2602.?”
}
},
{
“regexp”: {
“series_name”: “.?2602.?”
}
},
{
“regexp”: {
“name”: “.?2602.?”
}
}
]
}
}
}
结果是must_not and should
{
“query”: {
“bool”: {
“must”: [
{
“term”: {
“item_type”: 4
}
},
{
“term”: {
“can_see”: true
}
}
],
“should”: [
{
“regexp”: {
“item_no”: “.?2602.?”
}
},
{
“regexp”: {
“description”: “.?2602.?”
}
},
{
“regexp”: {
“series_name”: “.?2602.?”
}
},
{
“regexp”: {
“name”: “.?2602.?”
}
}
]
}
}
}
结果是must or should
原因是:bool查询也是采用more_matches_is_better的机制,因此满足must和should子句的文档将会合并起来计算分值。
elasticsearch bool 的坑
最新推荐文章于 2024-06-22 11:57:18 发布