mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 05:53:13 +00:00

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
57 lines
1.6 KiB
PHP
57 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Alchemy\Phrasea\SearchEngine\Elastic\AST;
|
|
|
|
use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryContext;
|
|
use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryHelper;
|
|
use Alchemy\Phrasea\SearchEngine\Elastic\Search\TextQueryHelper;
|
|
|
|
class QuotedTextNode extends Node
|
|
{
|
|
private $text;
|
|
|
|
public function __construct($text)
|
|
{
|
|
$this->text = $text;
|
|
}
|
|
|
|
public function buildQuery(QueryContext $context)
|
|
{
|
|
$query_builder = function (array $fields) use ($context) {
|
|
$index_fields = [];
|
|
foreach ($fields as $field) {
|
|
foreach ($context->localizeField($field) as $index_fields[]);
|
|
}
|
|
if (!$index_fields) {
|
|
return null;
|
|
}
|
|
return [
|
|
'multi_match' => [
|
|
'type' => 'phrase',
|
|
'fields' => $index_fields,
|
|
'query' => $this->text,
|
|
]
|
|
];
|
|
};
|
|
|
|
$query = $query_builder($context->getUnrestrictedFields());
|
|
$private_fields = $context->getPrivateFields();
|
|
$private_fields = TextQueryHelper::filterCompatibleFields($private_fields, $this->text);
|
|
foreach (QueryHelper::wrapPrivateFieldQueries($private_fields, $query_builder) as $private_field_query) {
|
|
$query = QueryHelper::applyBooleanClause($query, 'should', $private_field_query);
|
|
}
|
|
|
|
return $query;
|
|
}
|
|
|
|
public function getTermNodes()
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public function __toString()
|
|
{
|
|
return sprintf('<exact_text:"%s">', $this->text);
|
|
}
|
|
}
|