我有一些RE = 5和RE = 17的记录,我需要那些仅具有RE = 5的记录,而没有那些具有RE = 5和RE = 17的记录。请帮助:
我的样本记录
{
"RE": "17",
"RT": "278",
"PT": "2019-04-16T02:28:01",
"DT": "2019-04-16T02:15:18",
"ZI": "221853184142816817"
},
{
"RE": "5",
"RT": "278",
"PT": "2019-04-16T02:28:01",
"DT": "2019-04-16T02:15:18",
"ZI": "221853184142816817"
},
{
"RE": "5",
"RT": "278",
"PT": "2019-04-16T14:28:01",
"DT": "2019-04-16T14:15:18",
"ZI": "2218531841428168"
},
{
"RE": "5",
"RT": "270",
"PT": "2019-04-15T14:28:01",
"DT": "2019-04-15T14:15:18",
"ZI": "2218531841428168"
}
我已应用查询,但仍然得到此文档ZI = 221853184142816817属于RE = 17的那些人
{
"query": {
"bool": {
"should": [
{
"bool": {
"must": [
{
"term": {
"RE": "5"
}
}
],
"must_not": [
{
"term": {
"RE": {
"value": "17"
}
}
}
]
}
},
{
"bool": {
"must": [
{
"term": {
"RE": "5"
}
}
]
}
}
]
}
}
}
因此,请更正查询,以便我仅获取那些只有5个不需要的文档(不需要=>“ _id”:“ 221853184142816817_278_5”),同时具有RE = 5和RE = 17