mirror of
https://github.com/vrana/adminer.git
synced 2025-08-09 08:06:59 +02:00
Fix searching if "anywhere" field is selected
- Allow to search only in fields with index.
This commit is contained in:
@@ -130,9 +130,25 @@ if (isset($_GET["elastic"])) {
|
||||
}
|
||||
}
|
||||
foreach ($where as $val) {
|
||||
if (preg_match('~^\((.+ OR .+)\)$~', $val, $matches)) {
|
||||
$parts = explode(" OR ", $matches[1]);
|
||||
$terms = array();
|
||||
foreach ($parts as $part) {
|
||||
list($col, $op, $val) = explode(" ", $part, 3);
|
||||
$term = array($col => $val);
|
||||
if ($op == "=") {
|
||||
$terms[] = array("term" => $term);
|
||||
} elseif (in_array($op, array("must", "should", "must_not"))) {
|
||||
$data["query"]["bool"][$op][]["match"] = $term;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($terms)) {
|
||||
$data["query"]["bool"]["filter"][]["bool"]["should"] = $terms;
|
||||
}
|
||||
} else {
|
||||
list($col, $op, $val) = explode(" ", $val, 3);
|
||||
if ($col . $val != "") {
|
||||
$term = array(($col != "" ? $col : "_all") => $val);
|
||||
$term = array($col => $val);
|
||||
if ($op == "=") {
|
||||
$data["query"]["bool"]["filter"][] = array("term" => $term);
|
||||
} elseif (in_array($op, array("must", "should", "must_not"))) {
|
||||
@@ -366,6 +382,7 @@ if (isset($_GET["elastic"])) {
|
||||
);
|
||||
|
||||
foreach ($mappings as $name => $field) {
|
||||
if (!isset($field["index"]) || $field["index"]) {
|
||||
$return[$name] = array(
|
||||
"field" => $name,
|
||||
"full_type" => $field["type"],
|
||||
@@ -381,6 +398,7 @@ if (isset($_GET["elastic"])) {
|
||||
unset($return[$name]["privileges"]["update"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user