Nested filter with multiple term queries

(Tharindu Galappaththi) #1

I'm trying to use elasticsearch(6.7) sorting with multiple term queries. But it doesn't sort data when there are 3 term queries. It works when I specify only

 {
    "term": {
       "instance.instFields.sourceFieldId": {
         "value": "16044"
       }
    }
 },

Below is the sort query with all 3 terms.

"sort": [
    {
        "instance.instFields.fieldDate": {
            "order": "desc",
            "nested_path": "instance.instFields",
            "nested_filter": {
                "bool": {
                    "must": [
                        {
                            "term": {
                                "instance.instFields.sourceFieldId": {
                                    "value": "16044"
                                }
                            }
                        },
                        {
                            "term": {
                                "instance.dataSourceId": {
                                    "value": "819"
                                }
                            }
                        },
                        {
                            "term": {
                                "instance.dsTypeId": {
                                    "value": "2301"
                                }
                            }
                        }
                    ]
                }
            }
        }
    }
],

Appreciate any help to resolve this issue.