mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 22:13:13 +00:00
Fix number field search
Search with non numeric content will not hit number field (it breaks elasticsearch and is useless anyway) - Rename QueryHelper::buildPrivateFieldQueries() to wrapPrivateFieldQuery(). - Signature changed too, the third parameter is dropped an QueryContext is replaced by an array of Field. - Query builder closure is now passed an array of Field, not of index field names. - Remove Field::toConceptPathIndexFieldArray() because method name was beyond understanding (and also because it wasn't needed anymore) - Various AST node types have changed due to previous API changes
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Alchemy\Phrasea\SearchEngine\Elastic\Search;
|
||||
|
||||
use Alchemy\Phrasea\SearchEngine\Elastic\Mapping;
|
||||
|
||||
class TextQueryHelper
|
||||
{
|
||||
private function __construct() {}
|
||||
|
||||
public static function filterCompatibleFields(array $fields, $query_text)
|
||||
{
|
||||
$is_numeric = is_numeric($query_text);
|
||||
$filtered = [];
|
||||
foreach ($fields as $field) {
|
||||
switch ($field->getType()) {
|
||||
case Mapping::TYPE_FLOAT:
|
||||
case Mapping::TYPE_DOUBLE:
|
||||
case Mapping::TYPE_INTEGER:
|
||||
case Mapping::TYPE_LONG:
|
||||
case Mapping::TYPE_SHORT:
|
||||
case Mapping::TYPE_BYTE:
|
||||
if ($is_numeric) {
|
||||
$filtered[] = $field;
|
||||
}
|
||||
break;
|
||||
case Mapping::TYPE_STRING:
|
||||
case Mapping::TYPE_DATE:
|
||||
default:
|
||||
$filtered[] = $field;
|
||||
}
|
||||
}
|
||||
return $filtered;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user