【发布时间】:2020-06-22 01:56:08
【问题描述】:
我有这样的弹性数据
{
"xId" : "25b35718-1804-428e-87fc-e215422d21a0",
"date" : "2019-10-13T07:07:07.558Z",
"type" : "promo",
"accountId" : 50,
"readBy" : [
"b",
"a"
]
}
我想检索具有多个条件的数据 ,所以我使用了should和must_not的查询,当我使用该查询时,数组返回空,但现在数据仍然出现,是不是缺少了什么?
这是我的示例查询
{"query": {
"constant_score": {
"filter": {
"bool": {
"should": [
{
"terms": {
"accountId": [50]
}
},{
"terms": {
"type": ["promo"]
}
},
{
"match": {
"userId": "a"
}
}
],
"must_not": [
{
"terms": {
"type": []
}
}, {
"terms": {
"readBy": ["a"]
}
}
]
}
}
}
}
}
【问题讨论】:
-
您的示例文档中没有任何
userId字段。 -
另外,你为什么要说‘terms type:[]’?是否要排除空数组?
标签: elasticsearch elasticsearch-query term-query