2016-03-05 74 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} } 
]