Add highlights query

This commit is contained in:
Nicolas Le Goff
2014-12-29 15:06:45 +01:00
committed by Benoît Burnichon
parent 1ef4c1300d
commit 2d5a36f5a2
18 changed files with 120 additions and 41 deletions

View File

@@ -268,6 +268,12 @@ class ElasticSearchEngine implements SearchEngineInterface
$params['body']['from'] = $offset;
$params['body']['size'] = $perPage;
$params['body']['highlight'] = [
'pre_tags' => ['[[em]]'],
'post_tags' => ['[[/em]]'],
'order' => 'score',
'fields' => ['caption.*' => new \stdClass()]
];
if ($aggs = $this->getAggregationQueryParams($options)) {
$params['body']['aggs'] = $aggs;
@@ -280,7 +286,7 @@ class ElasticSearchEngine implements SearchEngineInterface
$n = 0;
foreach ($res['hits']['hits'] as $hit) {
$results[] = ElasticsearchRecordHydrator::hydrate($hit['_source'], $n++);
$results[] = ElasticsearchRecordHydrator::hydrate($hit, $n++);
}
$facets = $this->facetsResponseFactory->__invoke($res);