mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00

- Look for text nodes and infer the concepts behind term using thesaurus - Use value objects for thesaurus terms and concepts - Pass a QueryContext holding allowed fields and locales informations when building the Elasticsearch query - Change type hinting and name of query building method on nodes - Remove unused method Node#isFullTextOnly() - Move getFieldsStructure from RecordIndexer to RecordHelper for reusing field structure in SearchEngine
41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Alchemy\Phrasea\SearchEngine\Elastic\Search;
|
|
|
|
class QueryContext
|
|
{
|
|
private $fields;
|
|
private $locales;
|
|
private $queryLocale;
|
|
|
|
public function __construct(array $fields, array $locales, $queryLocale)
|
|
{
|
|
$this->fields = $fields;
|
|
$this->locales = $locales;
|
|
$this->queryLocale = $queryLocale;
|
|
}
|
|
|
|
public function narrowToFields(array $fields)
|
|
{
|
|
// Ensure we are not escaping from original fields restrictions
|
|
$fields = array_intersect($this->fields, $fields);
|
|
|
|
return new static($fields, $this->locales, $this->queryLocale);
|
|
}
|
|
|
|
public function getLocalizedFields()
|
|
{
|
|
$fields = array();
|
|
foreach ($this->fields as $field) {
|
|
foreach ($this->locales as $locale) {
|
|
$boost = ($locale === $this->queryLocale) ? '^5' : '';
|
|
$fields[] = sprintf('caption.%s.%s%s', $field, $locale, $boost);
|
|
}
|
|
// TODO Put generic analyzers on main field instead of "light" sub-field
|
|
$fields[] = sprintf('caption.%s.%s', $field, 'light^10');
|
|
}
|
|
|
|
return $fields;
|
|
}
|
|
}
|