]> git.joonet.de Git - adminer.git/commitdiff
ElasticSearch: table_statuses() also return count of rows
authorTomas Lang <tomas.lang@gmail.com>
Mon, 24 Mar 2014 18:21:34 +0000 (19:21 +0100)
committerJakub Vrana <jakub@vrana.cz>
Tue, 25 Mar 2014 16:36:07 +0000 (09:36 -0700)
adminer/drivers/elastic.inc.php

index 822ccf70b92e19c7b9482cd5a6bc489839cce98e..f5d749e8b7afedc379d3059cc963449ef56e1517 100644 (file)
@@ -224,10 +224,24 @@ if (isset($_GET["elastic"])) {
        }
 
        function table_status($name = "", $fast = false) {
-               $return = tables_list();
-               if ($return) {
-                       foreach ($return as $key => $type) { // _stats have just info about database
-                               $return[$key] = array("Name" => $key, "Engine" => $type);
+               global $connection;
+               $search = $connection->query("_search?search_type=count", array(
+                       "facets" => array(
+                               "count_by_type" => array(
+                                       "terms" => array(
+                                               "field" => "_type"
+                                       )
+                               )
+                       )
+               ), "POST");
+               $return = array();
+               if ($search) {
+                       foreach ($search["facets"]["count_by_type"]["terms"] as $table) {
+                               $return[$table["term"]] = array(
+                                       "Name" => $table["term"],
+                                       "Engine" => "table",
+                                       "Rows" => $table["count"]
+                               );
                        }
                        if ($name != "") {
                                return $return[$name];