Sort documents by inner json fields (string and date)


(Dionysis Lorentzos) #1

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/065e61bc-f9e3-49aa-b53e-ba0f73780717%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #2