PHRAS-3389_use-only-conceptpaths-from-selected-dbs_MASTER

fix : fixed preview was not displayed (caused by missing di)
This commit is contained in:
jygaulier
2021-04-14 09:56:16 +02:00
parent e1766103a6
commit 374e617d2e
4 changed files with 19 additions and 20 deletions

View File

@@ -11,29 +11,27 @@
namespace Alchemy\Phrasea\SearchEngine\Elastic; namespace Alchemy\Phrasea\SearchEngine\Elastic;
use Alchemy\Phrasea\Collection\Reference\CollectionReference; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Exception\LogicException; use Alchemy\Phrasea\Exception\LogicException;
use Alchemy\Phrasea\Exception\RuntimeException;
use Alchemy\Phrasea\Model\Entities\FeedEntry;
use Alchemy\Phrasea\SearchEngine\Elastic\Indexer\RecordIndexer; use Alchemy\Phrasea\SearchEngine\Elastic\Indexer\RecordIndexer;
use Alchemy\Phrasea\SearchEngine\Elastic\Search\AggregationHelper; use Alchemy\Phrasea\SearchEngine\Elastic\Search\AggregationHelper;
use Alchemy\Phrasea\SearchEngine\Elastic\Search\FacetsResponse; use Alchemy\Phrasea\SearchEngine\Elastic\Search\FacetsResponse;
use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryCompiler; use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryCompiler;
use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryContext; use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryContext;
use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryContextFactory; use Alchemy\Phrasea\SearchEngine\Elastic\Search\QueryContextFactory;
use Alchemy\Phrasea\SearchEngine\Elastic\Structure\Field AS ESField; use Alchemy\Phrasea\SearchEngine\Elastic\Structure\Field as ESField;
use Alchemy\Phrasea\SearchEngine\Elastic\Structure\Flag; use Alchemy\Phrasea\SearchEngine\Elastic\Structure\Flag;
use Alchemy\Phrasea\SearchEngine\Elastic\Structure\GlobalStructure; use Alchemy\Phrasea\SearchEngine\Elastic\Structure\GlobalStructure;
use Alchemy\Phrasea\SearchEngine\Elastic\Structure\Structure; use Alchemy\Phrasea\SearchEngine\Elastic\Structure\Structure;
use Alchemy\Phrasea\SearchEngine\SearchEngineInterface; use Alchemy\Phrasea\SearchEngine\SearchEngineInterface;
use Alchemy\Phrasea\SearchEngine\SearchEngineOptions; use Alchemy\Phrasea\SearchEngine\SearchEngineOptions;
use Alchemy\Phrasea\SearchEngine\SearchEngineResult; use Alchemy\Phrasea\SearchEngine\SearchEngineResult;
use Alchemy\Phrasea\Exception\RuntimeException;
use Alchemy\Phrasea\SearchEngine\SearchEngineStructure;
use Alchemy\Phrasea\Utilities\Stopwatch; use Alchemy\Phrasea\Utilities\Stopwatch;
use Closure; use Closure;
use Doctrine\Common\Collections\ArrayCollection;
use Alchemy\Phrasea\Model\Entities\FeedEntry;
use Alchemy\Phrasea\Application;
use databox_field; use databox_field;
use Doctrine\Common\Collections\ArrayCollection;
use Elasticsearch\Client; use Elasticsearch\Client;
class ElasticSearchEngine implements SearchEngineInterface class ElasticSearchEngine implements SearchEngineInterface
@@ -284,9 +282,8 @@ class ElasticSearchEngine implements SearchEngineInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function query($queryText, SearchEngineOptions $options = null) public function query($queryText, SearchEngineOptions $options)
{ {
$options = $options ?: new SearchEngineOptions();
$context = $this->context_factory->createContext($options); $context = $this->context_factory->createContext($options);
/** @var QueryCompiler $query_compiler */ /** @var QueryCompiler $query_compiler */

View File

@@ -167,7 +167,7 @@ interface SearchEngineInterface
* *
* @return SearchEngineResult * @return SearchEngineResult
*/ */
public function query($query, SearchEngineOptions $options = null); public function query($query, SearchEngineOptions $options);
/** /**
* Return an array of suggestions corresponding to the last word of the * Return an array of suggestions corresponding to the last word of the

View File

@@ -14,13 +14,12 @@ namespace Alchemy\Phrasea\SearchEngine;
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Authentication\ACLProvider; use Alchemy\Phrasea\Authentication\ACLProvider;
use Alchemy\Phrasea\Authentication\Authenticator; use Alchemy\Phrasea\Authentication\Authenticator;
use Alchemy\Phrasea\Collection\CollectionRepository;
use Alchemy\Phrasea\Collection\Reference\CollectionReference; use Alchemy\Phrasea\Collection\Reference\CollectionReference;
use Alchemy\Phrasea\Collection\Reference\DbalCollectionReferenceRepository; use Alchemy\Phrasea\Collection\Reference\CollectionReferenceRepository;
use Assert\Assertion; use Assert\Assertion;
use databox_descriptionStructure;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use databox_descriptionStructure;
class SearchEngineOptions class SearchEngineOptions
{ {
@@ -41,7 +40,7 @@ class SearchEngineOptions
const SORT_MODE_ASC = 'asc'; const SORT_MODE_ASC = 'asc';
const SORT_MODE_DESC = 'desc'; const SORT_MODE_DESC = 'desc';
/** @var DbalCollectionReferenceRepository $dbalCollectionReferenceRepository */ /** @var CollectionReferenceRepository */
private $collectionReferenceRepository; private $collectionReferenceRepository;
/** @var string */ /** @var string */
@@ -455,6 +454,11 @@ class SearchEngineOptions
return $this->date_fields; return $this->date_fields;
} }
public function __construct(CollectionReferenceRepository $collectionReferenceRepository)
{
$this->collectionReferenceRepository = $collectionReferenceRepository;
}
/** /**
* Creates options based on a Symfony Request object * Creates options based on a Symfony Request object
* *
@@ -469,9 +473,7 @@ class SearchEngineOptions
$authenticator = $app->getAuthenticator(); $authenticator = $app->getAuthenticator();
$isAuthenticated = $authenticator->isAuthenticated(); $isAuthenticated = $authenticator->isAuthenticated();
$options = new static(); $options = new static($app['repo.collection-references']);
$options->collectionReferenceRepository = $app['repo.collection-references'];
$options->disallowBusinessFields(); $options->disallowBusinessFields();
$options->setLocale($app['locale']); $options->setLocale($app['locale']);
@@ -713,7 +715,7 @@ class SearchEngineOptions
throw new \InvalidArgumentException('SearchEngineOptions data are corrupted'); throw new \InvalidArgumentException('SearchEngineOptions data are corrupted');
} }
$options = new static(); $options = new static($app['repo.collection-references']);
$options->disallowBusinessFields(); $options->disallowBusinessFields();
$methods = self::getHydrateMethods($app); $methods = self::getHydrateMethods($app);

View File

@@ -93,7 +93,7 @@ class record_preview extends record_adapter
throw new \LogicException('Search Engine should be provided'); throw new \LogicException('Search Engine should be provided');
} }
if (!$options) { if (!$options) {
$options = new SearchEngineOptions(); $options = new SearchEngineOptions($app['repo.collection-references']);
} }
$options->setFirstResult($pos); $options->setFirstResult($pos);
$options->setMaxResults(1); $options->setMaxResults(1);
@@ -197,7 +197,7 @@ class record_preview extends record_adapter
switch ($this->env) { switch ($this->env) {
case 'RESULT': case 'RESULT':
$options = $this->options ?: new SearchEngineOptions(); $options = $this->options ?: new SearchEngineOptions($this->app['repo.collection-references']);
$options->setFirstResult(($this->pos - 3) < 0 ? 0 : ($this->pos - 3)); $options->setFirstResult(($this->pos - 3) < 0 ? 0 : ($this->pos - 3));
$options->setMaxResults(56); $options->setMaxResults(56);