最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Elasticsearch returns a document which does not meet the criteria - Stack Overflow

programmeradmin0浏览0评论

I use the following DSL to retrieve documents from the Elasticsearch.

{
    "query": {
        "bool": {
            "boost": 1.0,
            "must": [
                {
                    "term": {
                        "hcAccountabilityOfficeCode.keyword": {
                            "value": "550"
                        }
                    }
                },
                {
                    "nested": {
                        "boost": 1.0,
                        "ignore_unmapped": false,
                        "path": "hearingActionDetails",
                        "query": {
                            "term": {
                                "hearingActionDetails.haaActionTypeCode.keyword": {
                                    "value": "SU"
                                }
                            }
                        },
                        "score_mode": "none"
                    }
                },
                {
                    "nested": {
                        "boost": 1.0,
                        "ignore_unmapped": false,
                        "path": "hearingActionDetails",
                        "query": {
                            "term": {
                                "hearingActionDetails.haaActionCatCode.keyword": {
                                    "value": "A"
                                }
                            }
                        },
                        "score_mode": "none"
                    }
                },
                {
                    "bool": {
                        "boost": 1.0,
                        "must_not": [
                            {
                                "term": {
                                    "hcStatusCode.keyword": {
                                        "value": "STS54"
                                    }
                                }
                            }
                        ]
                    }
                },
                {
                    "nested": {
                        "boost": 1.0,
                        "ignore_unmapped": false,
                        "path": "hearingActionDetails",
                        "query": {
                            "bool": {
                                "boost": 1.0,
                                "must_not": [
                                    {
                                        "exists": {
                                            "boost": 1.0,
                                            "field": "hearingActionDetails.haaPartyRespRcvdOn"
                                        }
                                    }
                                ]
                            }
                        },
                        "score_mode": "none"
                    }
                },
                {
                    "nested": {
                        "boost": 1.0,
                        "ignore_unmapped": false,
                        "path": "hearingActionDetails",
                        "query": {
                            "bool": {
                                "boost": 1.0,
                                "must_not": [
                                    {
                                        "exists": {
                                            "boost": 1.0,
                                            "field": "hearingActionDetails.haaPartyReplyRcvdOn"
                                        }
                                    }
                                ]
                            }
                        },
                        "score_mode": "none"
                    }
                }
            ]
        }
    }
}

The document which it returns does not meet the conditions. For example, the following document is returned. However, the document has "haaPartyRespRcvdOn" and "haaPartyReplyRcvdOn" populated in the nested array.

{
    "_index": "hearing-02-05-2025-10-49-45",
    "_id": "274",
    "_score": null,
    "_source": {
        "hcHearingCaseId": 274,
        "hcCaseNumber": "550-2025-00005",
        "hcAgencyNumber": "SF24-101001A",
        "hcStatusId": 742,
        "hcStatusCode": "STS11",
        "hearingActionDetails": [
            {
                "haaHearingActionId": 112,
                "haaActionCatId": 954,
                "haaActionCatCode": "A",
                "haaActionCatDesc": "Motions",
                "haaActionTypeId": 974,
                "haaActionTypeCode": "DS",
                "haaActionTypeDesc": "Discovery",
                "haaActionStatusId": null,
                "haaActionStatusCode": null,
                "haaActionStatusDescription": null,
                "haaReqPartyTypeId": 926,
                "haaReqPartyTypeCode": "A",
                "haaReqPartyTypeDesc": "Agency",
                "haaSurReplyStatusId": 991,
                "haaSurReplyStatusCode": "A",
                "haaSurReplyStatusDescription": "Granted",
                "haaSurReplySubById": null,
                "haaSurReplySubByCode": null,
                "haaSurReplyReqByDescription": null,
                "haaReceivedOn": "10-16-2024",
                "haaPartyRespDueSetOn": "10-16-2024",
                "haaPartyRespDueOn": "11-06-2024",
                "haaPartyRespRcvdOn": "10-16-2024",
                "haaPartyReplyDueOn": "10-23-2024",
                "haaPartyReplyRcvdOn": "10-16-2024",
                "haaRespRcvdFrmAgcyOn": null,
                "haaRespRcvdFrmCompOn": null,
                "haaSurReplySubOn": null,
                "haaSurReplyRespDueOn": "10-23-2024",
                "haaSurReplyRespRcvdOn": null,
                "haaOrderDueOn": "10-22-2024",
                "haaIssuedOn": null,
                "haaRespRecdFrmAgcyOn": null,
                "haaRespRecdFrmCompOn": null,
                "hacCreatedOn": "10-16-2024",
                "hacMotionSurReplyRecdOn": null,
                "hacSurReplyStatusUpdatedOn": null
            },
            {
                "haaHearingActionId": 374,
                "haaActionCatId": 954,
                "haaActionCatCode": "A",
                "haaActionCatDesc": "Motions",
                "haaActionTypeId": 920,
                "haaActionTypeCode": "SU",
                "haaActionTypeDesc": "Summary Judgement",
                "haaActionStatusId": 971,
                "haaActionStatusCode": "C",
                "haaActionStatusDescription": "Granted in Full for Complainant",
                "haaReqPartyTypeId": 927,
                "haaReqPartyTypeCode": "C",
                "haaReqPartyTypeDesc": "Complainant",
                "haaSurReplyStatusId": null,
                "haaSurReplyStatusCode": null,
                "haaSurReplyStatusDescription": null,
                "haaSurReplySubById": null,
                "haaSurReplySubByCode": null,
                "haaSurReplyReqByDescription": null,
                "haaReceivedOn": "01-03-2025",
                "haaPartyRespDueSetOn": null,
                "haaPartyRespDueOn": "01-21-2025",
                "haaPartyRespRcvdOn": "01-03-2025",
                "haaPartyReplyDueOn": "01-08-2025",
                "haaPartyReplyRcvdOn": "01-03-2025",
                "haaRespRcvdFrmAgcyOn": null,
                "haaRespRcvdFrmCompOn": null,
                "haaSurReplySubOn": null,
                "haaSurReplyRespDueOn": null,
                "haaSurReplyRespRcvdOn": null,
                "haaOrderDueOn": null,
                "haaIssuedOn": null,
                "haaRespRecdFrmAgcyOn": null,
                "haaRespRecdFrmCompOn": null,
                "hacCreatedOn": "01-03-2025",
                "hacMotionSurReplyRecdOn": null,
                "hacSurReplyStatusUpdatedOn": null
            }
        ]
    }
}

It returned the document I mentioned eventough the criteria clearly specified for "must_not" exist condtions for the nested field "hearingActionDetails.haaPartyReplyRcvdOn" and "hearingActionDetails.haaPartyRespRcvdOn".

发布评论

评论列表(0)

  1. 暂无评论