Merge pull request #1395 from jygaulier/PHRAS-442_FACETS-IN-API

PHRAS-442
This commit is contained in:
Benoît Burnichon
2015-06-29 17:55:56 +02:00
5 changed files with 47 additions and 15 deletions

View File

@@ -271,13 +271,13 @@ class ElasticSearchEngine implements SearchEngineInterface
$res = $this->client->search($params);
$results = new ArrayCollection();
$suggestions = new ArrayCollection();
$n = 0;
foreach ($res['hits']['hits'] as $hit) {
$results[] = ElasticsearchRecordHydrator::hydrate($hit, $n++);
}
/** @var FacetsResponse $facets */
$facets = $this->facetsResponseFactory->__invoke($res);
$query['ast'] = $this->app['query_compiler']->parse($string)->dump();
@@ -285,9 +285,20 @@ class ElasticSearchEngine implements SearchEngineInterface
$query['query'] = $params['body'];
$query['query_string'] = json_encode($params['body']);
return new SearchEngineResult($results, json_encode($query), $res['took'], $offset,
$res['hits']['total'], $res['hits']['total'], null, null, $suggestions, [],
$this->indexName, $facets);
return new SearchEngineResult(
$results, // ArrayCollection of results
json_encode($query),
$res['took'], // duration
$offset, // offset start
$res['hits']['total'], // available
$res['hits']['total'], // total
null, // error
null, // warning
$facets->getAsSuggestions(), // ArrayCollection of suggestions
[], // propositions
$this->indexName,
$facets
);
}
/**