In Elastic search 6.5 I have data with nested objects like this

    {  
        "_routing" : "City1",
        "_source" : {
        "city_name" : "City1",
        "brands" : [
            {
                "brand_code" : "BRCD01",
                "brand_name" : "Brand 1",
                "products_groups" : [
                    {
                        "group_id" : "001",
                        "products" : [
                            {
                                "pid" : "20",
                                "title" : "Product 1",
                                "mrp" : 100,
                                "sp" : 90,
                                "display_order" : 1
                            },
                            {
                                "pid" : "21",
                                "title" : "Product 2",
                                "mrp" : 100,
                                "sp" : 90,
                                "display_order" : 2
                            }
                        ]
                    },
                    {
                        "group_id" : "002",
                        "products" : [
                            {
                                "pid" : "22",
                                "title" : "Product 3",
                                "mrp" : 150,
                                "sp" : 130,
                                "display_order" : 3
                            },
                            {
                                "pid" : "23",
                                "title" : "Product 4",
                                "mrp" : 50,
                                "sp" : 20,
                                "display_order" : 4
                            }
                        ]
                    }
                ]
            },
            {
                "brand_code" : "BRCD02",
                "brand_name" : "Brand 2",
                "products_groups" : [
                    {
                        "group_id" : "003",
                        "products" : [
                            {
                                "pid" : "24",
                                "title" : "Product 5",
                                "mrp" : 100,
                                "sp" : 90,
                                "display_order" : 1
                            },
                            {
                                "pid" : "25",
                                "title" : "Product 6",
                                "mrp" : 100,
                                "sp" : 90,
                                "display_order" : 2
                            }
                        ]
                    },
                    {
                        "group_id" : "004",
                        "products" : [
                            {
                                "pid" : "26",
                                "title" : "Product 7",
                                "mrp" : 150,
                                "sp" : 130,
                                "display_order" : 3
                            },
                            {
                                "pid" : "27",
                                "title" : "Product 8",
                                "mrp" : 50,
                                "sp" : 20,
                                "display_order" : 4
                            }
                        ]
                    }
                ]
            }
        ]
    }
}

I want to sort on the field display_order inside the nested object products (brands.products_groups.products) with brand_code condition and routing.

I have tried with the nested query like this

    {
        "_source": false,
        "query" : {
            "bool" : {
            "must": [
                {
                    "term": {
                    "_routing" : "City1"
                    }
                },
                {
                    "nested": {
                        "path": "brands",
                        "inner_hits": {},
                        "query": {
                            "bool" : {
                                "must": [
                                    {
                                        "term" : {
                                                        brands.brand_code.keyword": "BRCD01"
                                        }                                   
                                                },                                  
                                                {
                                                    "nested": {                                 
                                                        "path": "brands.products_groups",                                       
                                                        "inner_hits": {                                       
                                                            "name": "brands_products_groups"                                        
                                                        },                      
                                                        "query": {
                                                "match_all": {}
                                            }                                 
                                                    }                                   
                                                }                               
                                            ]                           
                                        }
                            }
                        }
                        }
                    ]
                }
            },
                "sort" : [
                    {
                        "brands.products_groups.products.display_order": {
                            "order": "desc",
                            "mode" : "max",
                            "nested_path": "brands.products_groups.products"
                        }
                    }
                ]
            }

Sorting should be applicable on the inner_hits brands_products_groups. But it is not sorting based on the sort query.

Any idea how we can sort based on multi-level nested object field?