mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
Use ES hydrator to pouplate record from ES query
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Alchemy\Phrasea\SearchEngine\Elastic;
|
namespace Alchemy\Phrasea\SearchEngine\Elastic;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Model\Hydrator\ESRecordHydrator;
|
||||||
use Alchemy\Phrasea\SearchEngine\Elastic\Indexer\RecordIndexer;
|
use Alchemy\Phrasea\SearchEngine\Elastic\Indexer\RecordIndexer;
|
||||||
use Alchemy\Phrasea\SearchEngine\Elastic\Indexer\TermIndexer;
|
use Alchemy\Phrasea\SearchEngine\Elastic\Indexer\TermIndexer;
|
||||||
use Alchemy\Phrasea\SearchEngine\Elastic\Search\SearchQuery;
|
use Alchemy\Phrasea\SearchEngine\Elastic\Search\SearchQuery;
|
||||||
@@ -368,13 +369,9 @@ class ElasticSearchEngine implements SearchEngineInterface
|
|||||||
|
|
||||||
$results = new ArrayCollection();
|
$results = new ArrayCollection();
|
||||||
$suggestions = new ArrayCollection();
|
$suggestions = new ArrayCollection();
|
||||||
$n = 0;
|
|
||||||
|
|
||||||
foreach ($res['hits']['hits'] as $hit) {
|
foreach ($res['hits']['hits'] as $hit) {
|
||||||
$databoxId = is_array($hit['fields']['databox_id']) ? array_pop($hit['fields']['databox_id']) : $hit['fields']['databox_id'];
|
$results[] = ESRecordHydrator::hydrate($hit['_source']);
|
||||||
|
|
||||||
$recordId = is_array($hit['fields']['record_id']) ? array_pop($hit['fields']['record_id']) : $hit['fields']['record_id'];
|
|
||||||
$results[] = new \record_adapter($this->app, $databoxId, $recordId, $n++);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$query['_ast'] = $searchQuery->dump();
|
$query['_ast'] = $searchQuery->dump();
|
||||||
@@ -446,7 +443,6 @@ class ElasticSearchEngine implements SearchEngineInterface
|
|||||||
'index' => $this->indexName,
|
'index' => $this->indexName,
|
||||||
'type' => RecordIndexer::TYPE_NAME,
|
'type' => RecordIndexer::TYPE_NAME,
|
||||||
'body' => [
|
'body' => [
|
||||||
'fields' => ['databox_id', 'record_id'],
|
|
||||||
'sort' => $this->createSortQueryParams($options),
|
'sort' => $this->createSortQueryParams($options),
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
Reference in New Issue
Block a user