mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +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:
@@ -25,33 +25,38 @@ abstract class AbstractTermNode extends Node implements TermInterface
|
||||
$this->concepts = $concepts;
|
||||
}
|
||||
|
||||
protected function buildConceptQueries(QueryContext $context)
|
||||
protected function buildConceptQuery(QueryContext $context)
|
||||
{
|
||||
$concepts = Concept::pruneNarrowConcepts($this->concepts);
|
||||
if (!$concepts) {
|
||||
return [];
|
||||
return null;
|
||||
}
|
||||
|
||||
$queries_builder = function (array $index_fields) use ($concepts) {
|
||||
$queries = [];
|
||||
$query_builder = function (array $fields) use ($concepts) {
|
||||
$index_fields = [];
|
||||
foreach ($fields as $field) {
|
||||
$index_fields[] = $field->getConceptPathIndexField();
|
||||
}
|
||||
$query = null;
|
||||
foreach ($concepts as $concept) {
|
||||
$queries[] = [
|
||||
$concept_query = [
|
||||
'multi_match' => [
|
||||
'fields' => $index_fields,
|
||||
'query' => $concept->getPath()
|
||||
]
|
||||
];
|
||||
$query = QueryHelper::applyBooleanClause($query, 'should', $concept_query);
|
||||
}
|
||||
return $queries;
|
||||
return $query;
|
||||
};
|
||||
|
||||
$fields = $context->getUnrestrictedFields();
|
||||
$index_fields = Field::toConceptPathIndexFieldArray($fields);
|
||||
$query = $query_builder($context->getUnrestrictedFields());
|
||||
$private_fields = $context->getPrivateFields();
|
||||
foreach (QueryHelper::wrapPrivateFieldConceptQueries($private_fields, $query_builder) as $private_field_query) {
|
||||
$query = QueryHelper::applyBooleanClause($query, 'should', $private_field_query);
|
||||
}
|
||||
|
||||
$queries = $queries_builder($index_fields);
|
||||
foreach (QueryHelper::buildPrivateFieldConceptQueries($context, $queries_builder) as $queries[]);
|
||||
|
||||
return $queries;
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function getValue()
|
||||
|
Reference in New Issue
Block a user