Remove URL check from process.php. Checking is done in Crawler already
[phinde.git] / src / phinde / Elasticsearch.php
index 069cf1fefd74b495ea3a7aa6b4d11da8bf242a45..c24f6cd60b690f49baf32539d35c69d2be08071d 100644 (file)
@@ -58,14 +58,18 @@ class Elasticsearch
         $r->send();
     }
 
-    public function countDocuments()
+    public function getIndexStatus()
     {
         $r = new Elasticsearch_Request(
-            $this->baseUrl . 'document/_count',
+            $this->baseUrl . '_stats/docs,store',
             \HTTP_Request2::METHOD_GET
         );
         $res = $r->send();
-        return json_decode($res->getBody())->count;
+        $data = json_decode($res->getBody());
+        return array(
+            'documents' => $data->_all->total->docs->count,
+            'size'      => $data->_all->total->store->size_in_bytes,
+        );
     }
 
     public function search($query, $filters, $site, $page, $perPage, $sort)
@@ -131,6 +135,9 @@ class Elasticsearch
             )
         );
 
+        if ($sort == '' && $GLOBALS['phinde']['defaultSort'] == 'date') {
+            $sort = 'date';
+        }
         if ($sort == 'date') {
             $sortCfg = array('status.modate' => array('order' => 'desc'));
         } else {