# Nested Sort Not Working with query\_string?

**URL:** <https://discuss.elastic.co/t/nested-sort-not-working-with-query-string/100767>\
**Category:** Elasticsearch\
**Created:** [September 16, 2017, 2:38pm UTC](https://discuss.elastic.co/t/nested-sort-not-working-with-query-string/100767 "2017-09-16T14:38:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjaeger](https://avatars.discourse-cdn.com/v4/letter/r/13edae/32.png) [@rjaeger](https://discuss.elastic.co/u/rjaeger)\
**Post date:** [September 16, 2017, 2:38pm UTC](https://discuss.elastic.co/t/nested-sort-not-working-with-query-string/100767/1 "2017-09-16T14:38:47Z")

</div>

Thoughts on this?

When running this query:

{  
"query": {  
"bool": {  
"must": [  
{

```
      "query_string": {
        "query" : "*"
      }
    }]  
  }
}

```

,  
"sort": [  
{  
"values.value.keyword" : {  
"order" : "asc",  
"nested\_path": "values",  
"nested\_filter" : {  
"bool" : {  
"must": [  
{  
"match": {  
"[values.name](http://values.name)" : { "query" : "CreatedBy" }  
}  
}  
]  
}

```
    }
  }
}
]

```

}

The results are: (look for "\<------" for comments)  
{  
"took": 5,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 3,  
"max\_score": 4.8158913,  
"hits": [  
{  
"\_index": "contentobjecttest",  
"\_type": "contentobject",  
"\_id": "AV0aIcAmTKNRtcPZ6Eup",  
"\_score": 4.8158913,  
"\_source": {  
"teamId": "70b57943-c230-445e-925e-4a214a833ef9",  
"uniqueId": "000000001A",  
"values": [  
{  
"name": "Name",  
"value": "Test document.pdf",  
"objectPropertyId": "0cff2f1a-fb89-4683-b405-7dc67721892b",  
"propertyType": "string"  
},  
{  
"name": "CreatedDate",  
"value": "2017-06-26",  
"objectPropertyId": "cade3458-a379-4175-ae89-3f276b714567",  
"propertyType": "Date"  
},  
{  
"name": "CreatedBy",  
"value": "rjaeger@test.com", \<---------- NOT asc  
"objectPropertyId": "e8a41948-1a29-47f3-931f-8a418627ac38",  
"propertyType": "string"  
},  
{  
"name": "Version",  
"value": "1",  
"objectPropertyId": "de5eddb0-3538-458d-a05b-60086d93d17c",  
"propertyType": "int"  
}  
]  
}  
},  
{  
"\_index": "contentobjecttest",  
"\_type": "contentobject",  
"\_id": "AV0aIcBVTKNRtcPZ6Euq",  
"\_score": 3.2834144,  
"\_source": {  
"teamId": "70b57943-c230-445e-925e-4a214a833ef9",  
"uniqueId": "000000001E",  
"values": [  
{  
"name": "Name",  
"value": "Test document Ryan.pdf",  
"objectPropertyId": "c9b69f9e-82da-4064-8a43-8039882fbdb1",  
"propertyType": "string"  
},  
{  
"name": "CreatedDate",  
"value": "2017-04-07",  
"objectPropertyId": "eeab8d9c-1476-40a1-a924-f3edfa8d6dc7",  
"propertyType": "Date"  
},  
{  
"name": "CreatedBy",  
"value": "rjaeger@test.com", \<---------- NOT asc  
"objectPropertyId": "b367deee-9e90-4494-af46-b313132dac1f",  
"propertyType": "string"  
},  
{  
"name": "Version",  
"value": "25",  
"objectPropertyId": "26cb0196-a992-40f1-8f6e-cb65d1112d2a",  
"propertyType": "int"  
}  
]  
}  
},  
{  
"\_index": "contentobjecttest",  
"\_type": "contentobject",  
"\_id": "AV0aIcDiTKNRtcPZ6Euu",  
"\_score": 3.0726933,  
"\_source": {  
"teamId": "2e278344-7871-4ca1-bd6a-0cea3d746fda",  
"uniqueId": "000000002C",  
"productVersion": "1.1",  
"values": [  
{  
"name": "Name",  
"value": "Hello World.docx",  
"objectPropertyId": "e6d0de0d-3bf8-41cc-a8ca-0ff2def3628d",  
"propertyType": "string"  
},  
{  
"name": "CreatedDate",  
"value": "2017-05-07",  
"objectPropertyId": "296bacc7-fb26-46cf-b821-49a9d500efad",  
"propertyType": "Date"  
},  
{  
"name": "CreatedBy",  
"value": "jkennedy@test.com", \<---------- NOT asc  
"objectPropertyId": "18d3a146-6ca9-41c2-9620-05226090237d",  
"propertyType": "string"  
},  
{  
"name": "Version",  
"value": "1",  
"objectPropertyId": "37e9ee15-a642-4386-aea8-e57873d07c0f",  
"propertyType": "int"  
}  
]  
}  
}  
]  
}  
}

Ideas?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 14, 2017, 2:39pm UTC](https://discuss.elastic.co/t/nested-sort-not-working-with-query-string/100767/2 "2017-10-14T14:39:18Z")

</div>

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