mirror of
https://github.com/vrana/adminer.git
synced 2025-08-08 07:36:44 +02:00
Elastic: Fix text search on boolean fields
When searching in all fields for a text value, an error was thrown with ElasticSearch 7.17.23 when the index contains boolean fields: > query_shard_exception: failed to create query: > Can't parse boolean value [textvalue], expected [true] or [false] This patch fixes that problem by skipping boolean fields when the search word is not the string "true" or "false".
This commit is contained in:
committed by
Jakub Vrana
parent
4967a40410
commit
d5a17835ff
@@ -18,6 +18,7 @@ MS SQL: Remove support for MSSQL extension
|
||||
MS SQL: Add support for PDO_SQLSRV extension
|
||||
MS SQL: Link help from sys tables
|
||||
MongoDB: Remove support for deprecated extension mongo
|
||||
Elasticsearch: Fix text search on boolean fields
|
||||
|
||||
Adminer 4.17.1 (released 2025-02-25):
|
||||
MySQL: Fix typo in the date type (regression from 4.17.0)
|
||||
|
@@ -143,13 +143,23 @@ if (isset($_GET["elastic"])) {
|
||||
}
|
||||
}
|
||||
|
||||
$fields = null;
|
||||
foreach ($where as $val) {
|
||||
if (preg_match('~^\((.+ OR .+)\)$~', $val, $matches)) {
|
||||
$parts = explode(" OR ", $matches[1]);
|
||||
$terms = array();
|
||||
|
||||
if ($fields === null) {
|
||||
$fields = fields($table);
|
||||
}
|
||||
foreach ($parts as $part) {
|
||||
list($col, $op, $val) = explode(" ", $part, 3);
|
||||
$term = array($col => $val);
|
||||
if (isset($fields[$col]) && $fields[$col]['full_type'] == 'boolean'
|
||||
&& $val !== 'true' && $val !== 'false'
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
if ($op == "=") {
|
||||
$terms[] = array("term" => $term);
|
||||
} elseif (in_array($op, array("must", "should", "must_not"))) {
|
||||
|
Reference in New Issue
Block a user