排序
对查询结果进行排序
GET /user/docs/_search?sort=age:desc
GET /user/docs/_search?sort=age:desc
根据 age
倒序排序
{
"took" : 812,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 3,
"relation" : "eq"
},
"max_score" : null,
"hits" : [
{
"_index" : "user",
"_type" : "docs",
"_id" : "3",
"_score" : null,
"_source" : {
"name" : "王五",
"sex" : 1,
"age" : 26,
"address" : "河北省"
},
"sort" : [
26
]
},
{
"_index" : "user",
"_type" : "docs",
"_id" : "2",
"_score" : null,
"_source" : {
"name" : "李四",
"sex" : 1,
"age" : 25,
"address" : "河北省"
},
"sort" : [
25
]
},
{
"_index" : "user",
"_type" : "docs",
"_id" : "1",
"_score" : null,
"_source" : {
"name" : "张三",
"sex" : 1,
"age" : 24,
"address" : "河北省"
},
"sort" : [
24
]
}
]
}
}
{
"took" : 812,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 3,
"relation" : "eq"
},
"max_score" : null,
"hits" : [
{
"_index" : "user",
"_type" : "docs",
"_id" : "3",
"_score" : null,
"_source" : {
"name" : "王五",
"sex" : 1,
"age" : 26,
"address" : "河北省"
},
"sort" : [
26
]
},
{
"_index" : "user",
"_type" : "docs",
"_id" : "2",
"_score" : null,
"_source" : {
"name" : "李四",
"sex" : 1,
"age" : 25,
"address" : "河北省"
},
"sort" : [
25
]
},
{
"_index" : "user",
"_type" : "docs",
"_id" : "1",
"_score" : null,
"_source" : {
"name" : "张三",
"sex" : 1,
"age" : 24,
"address" : "河北省"
},
"sort" : [
24
]
}
]
}
}