elasticsearch
elasticsearch copied to clipboard
Order by date doesn't work?
When I use orderBy "date", which is defined as date "Y-m-d H:i:s" , it doesn't work, anyone can help?
Optlog::type('opt')->select('date')->search($search)->orderBy("date","desc")->paginate(10)->toArray();
result: array:12 [ "current_page" => 1 "data" => array:10 [ 0 => array:5 [ "date" => "2018-04-08 09:25:59" "_index" => "optlog" "_type" => "opt" "_id" => "AWKi3C_F0xeSFZ9_RGC4" "_score" => null ] 1 => array:5 [ "date" => "2018-04-08 09:59:24" "_index" => "optlog" "_type" => "opt" "_id" => "AWKi-sAx0xeSFZ9_RGC8" "_score" => null ] 2 => array:5 [ "date" => "2018-04-08 10:14:59" "_index" => "optlog" "_type" => "opt" "_id" => "AWKjCQNn0xeSFZ9_RGDE" "_score" => null ] 3 => array:5 [ "date" => "2018-04-08 09:48:59" "_index" => "optlog" "_type" => "opt" "_id" => "AWKi8TOf0xeSFZ9_RGC6" "_score" => null ] 4 => array:5 [ "date" => "2018-04-08 09:55:19" "_index" => "optlog" "_type" => "opt" "_id" => "AWKi9wAL0xeSFZ9_RGC7" "_score" => null ] 5 => array:5 [ "date" => "2018-04-04 18:51:35" "_index" => "optlog" "_type" => "opt" "_id" => "AWKQSIa10xeSFZ9_RGC2" "_score" => null ] 6 => array:5 [ "date" => "2018-04-04 18:51:09" "_index" => "optlog" "_type" => "opt" "_id" => "AWKQSCCz0xeSFZ9_RGC1" "_score" => null ] 7 => array:5 [ "date" => "2018-04-08 10:14:50" "_index" => "optlog" "_type" => "opt" "_id" => "AWKjCOAM0xeSFZ9_RGDD" "_score" => null ] 8 => array:5 [ "date" => "2018-04-04 18:50:43" "_index" => "optlog" "_type" => "opt" "_id" => "AWKQR72R0xeSFZ9_RGC0" "_score" => null ] 9 => array:5 [ "date" => "2018-04-08 13:47:45" "_index" => "optlog" "_type" => "opt" "_id" => "AWKjy83J0xeSFZ9_RGDL" "_score" => null ] ] "first_page_url" => "http://newadmin.ys7.com/common/searchOpt?search=&page=1" "from" => 1 "last_page" => 2 "last_page_url" => "http://newadmin.ys7.com/common/searchOpt?search=&page=2" "next_page_url" => "http://newadmin.ys7.com/common/searchOpt?search=&page=2" "path" => "http://newadmin.ys7.com/common/searchOpt" "per_page" => 10 "prev_page_url" => null "to" => 10 "total" => 18 ]