I'm new to Elasticsearch.
I have documents and each of them has a structure like this:
{
"created_at": "2018-01-01 01:01:01",
"student": {
"first_name": "john",
"last_name": "doe"
},
"parent": {
"first_name": "susan",
"last_name": "smile"
}
}
I just want to sort those documents based on student.first_name
using olivere/elastic
package for go
.
This is my query at the moment:
searchSvc = searchSvc.SortBy(elastic.NewFieldSort("student.first_name").Asc())
and I'm getting this error:
elastic: Error 400 (Bad Request): all shards failed [type=search_phase_execution_exception]
However when I tried sorting it by created_at
, it's working.
searchSvc = searchSvc.SortBy(elastic.NewFieldSort("created_at").Asc())
I don't have any mapping in the index. (is this the problem?)
I tried searching for something like "Elasticsearch sort by nested object", but I always got questions that need to sort an array in the nested object.