2016-03-05 200 views
0

我正在使用弹性搜索来搜索数据。我想按日期排序。 下面是我的网址搜索链接:排序弹性搜索

https://70e97e980f1ff0674f3524a35af2b603.us-east-1.aws.found.io:9243/episode/_search?q=news&size=10 

我想日期(出版日期)进行排序。我如何做到这一点?当我尝试下面的代码时,它不起作用。

https://70e97e980f1ff0674f3524a35af2b603.us-east-1.aws.found.io:9243/episode/_search?q=news&size=10&sort=pubdate&order:desc 

如何按降序排列?

回答

0

您的某些文档没有定义pubdate,并且ElasticSearch不会对空值进行排序。

使用此:

"sort" : [ 
     { "pubdate": {"order" : "desc" , "missing" : "_last" , "ignore_unmapped" : true} } 
]