ES查询不生效问题:
SQL如下:
{
"from": 0,
"size": 20,
"query": {
"bool": {
"must": [
{
"term": {
"companyId": 3211002
}
},
{
"bool": {
"should": [
{
"term": {
"hrId": 1005031
}
},
{
"terms": {
"manager": [
1005031
]
}
},
{
"bool": {
"must": [
{
"exists": {
"field": "manager"
}
},
{
"terms": {
"manager": []
}
}
]
}
},
{
"bool": {
"must_not": {
"exists": {
"field": "manager"
}
}
}
}
],
"minimum_should_match": "1"
}
},
{
"terms": {
"status": [
"0"
]
}
},
{
"bool": {
"should": [
{
"bool": {
"must_not": {
"exists": {
"field": "approvals"
}
}
}
},
{
"nested": {
"query": {
"terms": {
"approvals.approvalStatus": [
1
]
}
},
"path": "approvals"
}
}
],
"minimum_should_match": "1"
}
}
]
}
},
"sort": [
{
"createTime": {
"order": "desc"
}
}
]
}
为什么可以匹配到id为498的数据,求解答:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 2,
"max_score": null,
"hits": [
{
"_index": "recruitment",
"_type": "requirement",
"_id": "501",
"_score": null,
"_source": {
"id": 501,
"companyId": 3211002,
"hrId": 1005031,
"formId": 501,
"requirementId": "Test0004",
"positionTitle": "招聘需求004",
"positionProperties": 1,
"requirementCount": 3,
"requirementType": 1,
"reportTo": 1004651,
"requirementTeam": 188384773,
"requirementStatus": 0,
"manager": [
1005031
],
"status": 0,
"createTime": 1685350126881,
"hasAttachment": false
},
"sort": [
1685350126881
]
},
{
"_index": "recruitment",
"_type": "requirement",
"_id": "498",
"_score": null,
"_source": {
"id": 498,
"companyId": 3211002,
"hrId": 1004483,
"formId": 498,
"requirementId": "Test0002",
"positionTitle": "审批测试1",
"positionProperties": 2,
"requirementCount": 2,
"requirementStatus": 0,
"status": 0,
"createTime": 1685346243403,
"hasAttachment": false,
"approvals": [
{
"approvalStatus": 1,
"nodes": [
{
"approvers": [
{
"approverStatus": 3,
"id": 1005031
}
],
"nodeStatus": 3
},
{
"approvers": [
{
"approverStatus": 1,
"id": 1004789
},
{
"approverStatus": 1,
"id": 1004483
}
],
"nodeStatus": 1
}
],
"createTime": "2023-05-29T15:44:07+08:00",
"hrId": 1004483,
"id": 597
}
]
},
"sort": [
1685346243403
]
}
]
}
}