# Sort documents by inner json fields (string and date)

**URL:** <https://discuss.elastic.co/t/sort-documents-by-inner-json-fields-string-and-date/16509>\
**Category:** Elasticsearch\
**Created:** [March 20, 2014, 9:27pm UTC](https://discuss.elastic.co/t/sort-documents-by-inner-json-fields-string-and-date/16509 "2014-03-20T21:27:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dionysis\_Lorentzos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dionysis_lorentzos/32/1711_2.png) [@Dionysis\_Lorentzos](https://discuss.elastic.co/u/Dionysis_Lorentzos)\
**Post date:** [March 20, 2014, 9:27pm UTC](https://discuss.elastic.co/t/sort-documents-by-inner-json-fields-string-and-date/16509/1 "2014-03-20T21:27:50Z")

</div>

Assuming that this is my mapping:

{  
"event": {  
"properties": {  
"name": {  
"type": "string",  
"index": "analyzed",  
"fields": {  
"raw": {  
"type": "string",  
"index": "not\_analyzed"  
}  
}  
},  
"more": {  
"properties": {  
"title": {  
"type": "string",  
"index": "analyzed",  
"fields": {  
"raw": {  
"type": "string",  
"index": "not\_analyzed"  
}  
}  
},  
"start\_date": {  
"type": "date",  
"format": "yyyy-MM-dd'T'HH:mm:ssZ"  
}  
}  
}  
}  
}  
}

I can successfully get sorted results for `name.raw` like:

GET event/event/\_search

> {  
> "sort": [{ "name.raw": "asc" }]  
> }

However I have hard time when using `more.title.raw` and `more.start_date`  
as the results will display null in the returned sort field e.g.:

```
  "hits": [
     {
        "_index": "event",
        "_type": "event",
        "_id": "52f70fb1c36b446c340e93bf",
        "_score": null,
        "_source": {
           "name": "S. Walter Stewart Library",              
           "more": {
              "title": "Parent Led Sing Along Group",                 
              "start_date": "2014-02-12T20:15:00+00:00",               

           }
        },
        "sort": [
           null
        ]
     },
     ....
  ]

```

Is it possible with that schema to sort 1) by `more.title` 2) by  
`more.start_date` ?+how

Best,  
D

PS: I guess I can also use `"format":"date_time_no_millis"` in  
`"start_date"` field.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/065e61bc-f9e3-49aa-b53e-ba0f73780717%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/065e61bc-f9e3-49aa-b53e-ba0f73780717%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 1:41am UTC](https://discuss.elastic.co/t/sort-documents-by-inner-json-fields-string-and-date/16509/2 "2017-07-06T01:41:45Z")

</div>


