根据此链接describing the addition of sorting by nested fields to ElasticSearch:
根据所使用的sort_mode,在排序期间挑选最高(最大)或最低(最小)内部对象。
有没有办法,而不是使用最高或最低值,它使用数组的第一个值?例如,如果记录如下所示:
{
"title": "Blah blah blah",
"authors": [
{
"last": "Reiter",
"first": "Jordan",
},
{
"last": "Jim",
"first": "Lee",
}
]
}
我希望按authors.last, authors.first
排序,它会使用Reiter, Jordan
进行排序?
答案 0 :(得分:2)
不幸的是没有。
我建议在父文档中存储您想要排序的作者,即
title: "Blah blah"
sortByAuthor: "Jordan Reiter"
authors: [
...
]
你可以使用脚本来逃避当前的结构,但是你将在内存中加载更多的内容。