试试搜索一下吧

关于同意字段多个值查询是用should拼接效率高还是直接用多值查询效率高

Elasticsearch | 作者 guoyanbiao520 | 发布于2020年11月20日 | 阅读数:1218

因为项目查询比较复杂,每个查询都可能查询多个字段多个值,现在想一个字段查询多个值的时候是用should拼接查询效率高还是用多值查询比较快,如下两种查询:1.{
"profile": true,
"size":0,
"query":{
"terms":{
"status":["1","2","3"]
}
}
}
2.
{
"profile": true,
"size":0,
"query": {
"bool": {
"must": [{
"bool": {
"should": [{
"term": {
"status": "1"
}

},
{
"term": {
"status": "2"
}
},
{
"term": {
"status": "3"
}
}
]
}
}
]
}
}
}
已邀请:

FFFrp

赞同来自: laoyang360

建议使用1,使用2如果数量大于1024就会报错,而且易读性很差,你profile出来时哪个快呢

要回复问题请先登录注册