目前使用elasticsearch 的termsQuery操作组装in查询条件, in条件约2000+ ,导致了es的查询超时问题, 请问如何解决,有替代方案么,
{
"from" : 0,
"size" : 20,
"query" : {
"bool" : {
"must" : [ {
"range" : {
"bind_time" : {
"from" : 1594483200000,
"to" : 1597161599000,
"include_lower" : true,
"include_upper" : true
}
}
}, {
"terms" : {
"assistant_id" : [ 16113, 16116, 16120, 16121, 16123, 17664, 17735, 17737, 17738, 18689, 18957, 19113 ]
}
}, {
"terms" : {
"customer_id" : [ 8730756, 9085067, 8716418, 9050253, 9070722, 9074817........ 8607887, 8984709, 9050247, 9050267, 8870047, 8999057, 9058450, 716816, 3289132 ]
}
} ]
}
},
"sort" : [ {
"bind_time" : {
"order" : "desc",
"missing" : "_last"
}
} ]
}
customer_id 条件约为2000+条
{
"from" : 0,
"size" : 20,
"query" : {
"bool" : {
"must" : [ {
"range" : {
"bind_time" : {
"from" : 1594483200000,
"to" : 1597161599000,
"include_lower" : true,
"include_upper" : true
}
}
}, {
"terms" : {
"assistant_id" : [ 16113, 16116, 16120, 16121, 16123, 17664, 17735, 17737, 17738, 18689, 18957, 19113 ]
}
}, {
"terms" : {
"customer_id" : [ 8730756, 9085067, 8716418, 9050253, 9070722, 9074817........ 8607887, 8984709, 9050247, 9050267, 8870047, 8999057, 9058450, 716816, 3289132 ]
}
} ]
}
},
"sort" : [ {
"bind_time" : {
"order" : "desc",
"missing" : "_last"
}
} ]
}
customer_id 条件约为2000+条
3 个回复
liuxg - Elastic
赞同来自:
viewsite
赞同来自:
pony_maggie - 公众号:犀牛饲养员的技术笔记
赞同来自: