Use ES hydrator to pouplate record from ES query

This commit is contained in:
Nicolas Le Goff
2014-10-14 20:22:01 +02:00
parent 042da9d43e
commit d666880ada

View File

@@ -11,6 +11,7 @@
namespace Alchemy\Phrasea\SearchEngine\Elastic;
use Alchemy\Phrasea\Model\Hydrator\ESRecordHydrator;
use Alchemy\Phrasea\SearchEngine\Elastic\Indexer\RecordIndexer;
use Alchemy\Phrasea\SearchEngine\Elastic\Indexer\TermIndexer;
use Alchemy\Phrasea\SearchEngine\Elastic\Search\SearchQuery;
@@ -368,13 +369,9 @@ class ElasticSearchEngine implements SearchEngineInterface
$results = new ArrayCollection();
$suggestions = new ArrayCollection();
$n = 0;
foreach ($res['hits']['hits'] as $hit) {
$databoxId = is_array($hit['fields']['databox_id']) ? array_pop($hit['fields']['databox_id']) : $hit['fields']['databox_id'];
$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++);
$results[] = ESRecordHydrator::hydrate($hit['_source']);
}
$query['_ast'] = $searchQuery->dump();
@@ -446,7 +443,6 @@ class ElasticSearchEngine implements SearchEngineInterface
'index' => $this->indexName,
'type' => RecordIndexer::TYPE_NAME,
'body' => [
'fields' => ['databox_id', 'record_id'],
'sort' => $this->createSortQueryParams($options),
]
];