How to query - sort multiple nested fields in elasticsearch

I required multiple sorting in nested fields. I tried below code but it's not working. how can I do a multiple sorting in nested fields?

data is stored like this.

indent preformatted text by 4 spaces[
{
	"_index": "test",
	"_type": "data",
	"_id": "AXUz9qiooooGmNN",
	"_score": null,
	"_source": {
		"number_filters": [
			{
				 "masterid": "78772703",
				 "label": "unique_id",
				 "type": "number",
				 "value": [
					{
					   "value": 5831967
					}
				 ]
			},
			{
				 "masterid": "1536368343",
				 "label": "unique_id",
				 "type": "number",
				 "value": [
					{
					   "value": 2315458
					}
				 ]
			}
		]
	}
},
{
	"_index": "test",
	"_type": "data",
	"_id": "AXUz9qiooooG6lN",
	"_score": null,
	"_source": {
		"number_filters": [
			{
				 "masterid": "78772703",
				 "label": "unique_id",
				 "type": "number",
				 "value": [
					{
					   "value": 46332
					}
				 ]
			},
			{
				 "masterid": "1536368343",
				 "label": "unique_id",
				 "type": "number",
				 "value": [
					{
					   "value": 46646
					}
				 ]
			}
		]
	}
}

]

this is the code I tried for multiple sort.

 "sort" : [
       {
         "number_filters.value.value": {
            "order": "desc",
            "nested_path": "number_filters",
            "nested_filter": {
               "term": {
                  "number_filters.masterid": "78772703"
               }
            }
         }
      },
       {
         "number_filters.value.value": {
            "order": "asc",
            "nested_path": "number_filters",
            "nested_filter": {
               "term": {
                  "number_filters.masterid": "1536368343"
               }
            }
         }
      }
   ]

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.