我正在尝试使用一个嵌套对象对所有文档进行排序,因为每个对象“action”都是列表中显示的行,用户希望通过“vouch”对列表进行排序。
以下是ES中的数据:
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 2,
"successful": 2,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 1,
"hits": [
{
"_index": "qae-myobject1509618636",
"_type": "myobject",
"_id": "601708a8-684d-4321-910b-a6ac61f986a8",
"_score": 1,
"_source": {
"id": "601708a8-684d-4321-910b-a6ac61f986a8",
"actions": [
{
"id": "cc454d55-e49f-45d3-89a9-c898e8b05289",
"vouch": "C",
"notice": "0001-01-01T00:00:00+00:00"
}
,
{
"id": "2f1f5964-f4e2-4df2-8895-7c6535d09255",
"vouch": "B",
"notice": "0001-01-01T00:00:00+00:00"
}
]}
}
,
{
"_index": "qae-myobject1509618636",
"_type": "myobject",
"_id": "c7d59a3b-5c86-42d0-809c-139a996a3c34",
"_score": 1,
"_source": {
"id": "c7d59a3b-5c86-42d0-809c-139a996a3c34",
"actions": [
{
"id": "255dfb74-2576-414d-8d2d-63981ee92e73",
"vouch": "D",
"notice": "0001-01-01T00:00:00+00:00"
}
,
{
"id": "c26d56b8-144a-4bed-bbdc-7fdb2eca63b1",
"vouch": "A",
"notice": "0001-01-01T00:00:00+00:00"
}
]}
}
]
}
}
我需要按字母顺序按'保证'对所有'动作'(我的嵌套对象)进行排序。可悲的是,ES按文档排序“行动”。所以我有结果:
{B,C},{A,D}代替{A,B,C,D}
如何对文档进行排序以获得一个响应,并且所有嵌套对象都已正确排序(而不是按文档排序)。
感谢您的帮助。