mirror of
https://github.com/vrana/adminer.git
synced 2025-08-12 09:34:10 +02:00
Fix displaying type mapping for Elasticsearch >= 6.0
Earlier versions of Elasticsearch (<= 5) supported multiple types per index. That meant that you could have different data mappings for each type. With Elasticsearch 6, this was removed and you can only have single mapping type.
This commit is contained in:
@@ -7,7 +7,7 @@ if (isset($_GET["elastic"])) {
|
||||
|
||||
if (function_exists('json_decode') && ini_bool('allow_url_fopen')) {
|
||||
class Min_DB {
|
||||
var $extension = "JSON", $server_info, $errno, $error, $_url;
|
||||
var $extension = "JSON", $server_info, $errno, $error, $_url, $_db;
|
||||
|
||||
/** Performs query
|
||||
* @param string
|
||||
@@ -284,6 +284,11 @@ if (isset($_GET["elastic"])) {
|
||||
|
||||
function tables_list() {
|
||||
global $connection;
|
||||
|
||||
if (min_version(6)) {
|
||||
return array('_doc' => 'table');
|
||||
}
|
||||
|
||||
$return = $connection->query('_mapping');
|
||||
if ($return) {
|
||||
$return = array_fill_keys(array_keys($return[$connection->_db]["mappings"]), 'table');
|
||||
@@ -339,25 +344,35 @@ if (isset($_GET["elastic"])) {
|
||||
|
||||
function fields($table) {
|
||||
global $connection;
|
||||
$result = $connection->query("$table/_mapping");
|
||||
$return = array();
|
||||
if ($result) {
|
||||
$mappings = $result[$table]['properties'];
|
||||
if (!$mappings) {
|
||||
$mappings = $result[$connection->_db]['mappings'][$table]['properties'];
|
||||
|
||||
$mappings = array();
|
||||
if (min_version(6)) {
|
||||
$result = $connection->query("_mapping");
|
||||
if ($result) {
|
||||
$mappings = $result[$connection->_db]['mappings']['properties'];
|
||||
}
|
||||
if ($mappings) {
|
||||
foreach ($mappings as $name => $field) {
|
||||
$return[$name] = array(
|
||||
"field" => $name,
|
||||
"full_type" => $field["type"],
|
||||
"type" => $field["type"],
|
||||
"privileges" => array("insert" => 1, "select" => 1, "update" => 1),
|
||||
);
|
||||
if ($field["properties"]) { // only leaf fields can be edited
|
||||
unset($return[$name]["privileges"]["insert"]);
|
||||
unset($return[$name]["privileges"]["update"]);
|
||||
}
|
||||
} else {
|
||||
$result = $connection->query("$table/_mapping");
|
||||
if ($result) {
|
||||
$mappings = $result[$table]['properties'];
|
||||
if (!$mappings) {
|
||||
$mappings = $result[$connection->_db]['mappings'][$table]['properties'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$return = array();
|
||||
if ($mappings) {
|
||||
foreach ($mappings as $name => $field) {
|
||||
$return[$name] = array(
|
||||
"field" => $name,
|
||||
"full_type" => $field["type"],
|
||||
"type" => $field["type"],
|
||||
"privileges" => array("insert" => 1, "select" => 1, "update" => 1),
|
||||
);
|
||||
if ($field["properties"]) { // only leaf fields can be edited
|
||||
unset($return[$name]["privileges"]["insert"]);
|
||||
unset($return[$name]["privileges"]["update"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user