mirror of
https://github.com/vrana/adminer.git
synced 2025-08-08 23:57:29 +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) {
|
foreach ($where as $val) {
|
||||||
list($col, $op, $val) = explode(" ", $val, 3);
|
if (preg_match('~^\((.+ OR .+)\)$~', $val, $matches)) {
|
||||||
if ($col . $val != "") {
|
$parts = explode(" OR ", $matches[1]);
|
||||||
$term = array(($col != "" ? $col : "_all") => $val);
|
$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);
|
||||||
|
$term = array($col => $val);
|
||||||
if ($op == "=") {
|
if ($op == "=") {
|
||||||
$data["query"]["bool"]["filter"][] = array("term" => $term);
|
$data["query"]["bool"]["filter"][] = array("term" => $term);
|
||||||
} elseif (in_array($op, array("must", "should", "must_not"))) {
|
} elseif (in_array($op, array("must", "should", "must_not"))) {
|
||||||
@@ -366,19 +382,21 @@ if (isset($_GET["elastic"])) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
foreach ($mappings as $name => $field) {
|
foreach ($mappings as $name => $field) {
|
||||||
$return[$name] = array(
|
if (!isset($field["index"]) || $field["index"]) {
|
||||||
"field" => $name,
|
$return[$name] = array(
|
||||||
"full_type" => $field["type"],
|
"field" => $name,
|
||||||
"type" => $field["type"],
|
"full_type" => $field["type"],
|
||||||
"privileges" => array(
|
"type" => $field["type"],
|
||||||
"insert" => 1,
|
"privileges" => array(
|
||||||
"select" => 1,
|
"insert" => 1,
|
||||||
"update" => 1,
|
"select" => 1,
|
||||||
),
|
"update" => 1,
|
||||||
);
|
),
|
||||||
if ($field["properties"]) { // only leaf fields can be edited
|
);
|
||||||
unset($return[$name]["privileges"]["insert"]);
|
if ($field["properties"]) { // only leaf fields can be edited
|
||||||
unset($return[$name]["privileges"]["update"]);
|
unset($return[$name]["privileges"]["insert"]);
|
||||||
|
unset($return[$name]["privileges"]["update"]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
|
Reference in New Issue
Block a user