Elasticsearch: Don't use selectQueryBuild()
This commit is contained in:
parent
cff70ad1df
commit
b90a12bfb4
|
@ -90,40 +90,37 @@ if (isset($_GET["elastic"])) {
|
||||||
|
|
||||||
function select($table, $select, $where, $group, $order, $limit, $page, $print = false) {
|
function select($table, $select, $where, $group, $order, $limit, $page, $print = false) {
|
||||||
global $adminer;
|
global $adminer;
|
||||||
$query = $adminer->selectQueryBuild($select, $where, $group, $order, $limit, $page);
|
|
||||||
$data = array();
|
$data = array();
|
||||||
if (!$query) {
|
$query = "$table/_search";
|
||||||
$query = "$table/_search";
|
if ($select != array("*")) {
|
||||||
if ($select != array("*")) {
|
$data["fields"] = $select;
|
||||||
$data["fields"] = $select;
|
}
|
||||||
|
if ($order) {
|
||||||
|
$sort = array();
|
||||||
|
foreach ($order as $col) {
|
||||||
|
$col = preg_replace('~ DESC$~', '', $col, 1, $count);
|
||||||
|
$sort[] = ($count ? array($col => "desc") : $col);
|
||||||
}
|
}
|
||||||
if ($order) {
|
$data["sort"] = $sort;
|
||||||
$sort = array();
|
}
|
||||||
foreach ($order as $col) {
|
if ($limit) {
|
||||||
$col = preg_replace('~ DESC$~', '', $col, 1, $count);
|
$data["size"] = +$limit;
|
||||||
$sort[] = ($count ? array($col => "desc") : $col);
|
if ($page) {
|
||||||
}
|
$data["from"] = ($page * $limit);
|
||||||
$data["sort"] = $sort;
|
|
||||||
}
|
}
|
||||||
if ($limit) {
|
}
|
||||||
$data["size"] = +$limit;
|
foreach ((array) $_GET["where"] as $val) {
|
||||||
if ($page) {
|
if ("$val[col]$val[val]" != "") {
|
||||||
$data["from"] = ($page * $limit);
|
$term = array("match" => array(($val["col"] != "" ? $val["col"] : "_all") => $val["val"]));
|
||||||
|
if ($val["op"] == "=") {
|
||||||
|
$data["query"]["filtered"]["filter"]["and"][] = $term;
|
||||||
|
} else {
|
||||||
|
$data["query"]["filtered"]["query"]["bool"]["must"][] = $term;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ((array) $_GET["where"] as $val) {
|
}
|
||||||
if ("$val[col]$val[val]" != "") {
|
if ($data["query"] && !$data["query"]["filtered"]["query"]) {
|
||||||
$term = array("match" => array(($val["col"] != "" ? $val["col"] : "_all") => $val["val"]));
|
$data["query"]["filtered"]["query"] = array("match_all" => array());
|
||||||
if ($val["op"] == "=") {
|
|
||||||
$data["query"]["filtered"]["filter"]["and"][] = $term;
|
|
||||||
} else {
|
|
||||||
$data["query"]["filtered"]["query"]["bool"]["must"][] = $term;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($data["query"] && !$data["query"]["filtered"]["query"]) {
|
|
||||||
$data["query"]["filtered"]["query"] = array("match_all" => array());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ($print) {
|
if ($print) {
|
||||||
echo $adminer->selectQuery("$query: " . print_r($data, true));
|
echo $adminer->selectQuery("$query: " . print_r($data, true));
|
||||||
|
|
Loading…
Reference in a new issue