| @@ 20-42 (lines=23) @@ | ||
| 17 | /** |
|
| 18 | * Search aggregations dsl endpoint. |
|
| 19 | */ |
|
| 20 | class AggregationsEndpoint extends AbstractSearchEndpoint |
|
| 21 | { |
|
| 22 | /** |
|
| 23 | * Endpoint name |
|
| 24 | */ |
|
| 25 | const NAME = 'aggregations'; |
|
| 26 | ||
| 27 | /** |
|
| 28 | * {@inheritdoc} |
|
| 29 | */ |
|
| 30 | public function normalize(NormalizerInterface $normalizer, $format = null, array $context = []) |
|
| 31 | { |
|
| 32 | $output = []; |
|
| 33 | if (count($this->getAll()) > 0) { |
|
| 34 | /** @var AbstractAggregation $aggregation */ |
|
| 35 | foreach ($this->getAll() as $aggregation) { |
|
| 36 | $output[$aggregation->getName()] = $aggregation->toArray(); |
|
| 37 | } |
|
| 38 | } |
|
| 39 | ||
| 40 | return $output; |
|
| 41 | } |
|
| 42 | } |
|
| 43 | ||
| @@ 20-42 (lines=23) @@ | ||
| 17 | /** |
|
| 18 | * Search inner hits dsl endpoint. |
|
| 19 | */ |
|
| 20 | class InnerHitsEndpoint extends AbstractSearchEndpoint |
|
| 21 | { |
|
| 22 | /** |
|
| 23 | * Endpoint name |
|
| 24 | */ |
|
| 25 | const NAME = 'inner_hits'; |
|
| 26 | ||
| 27 | /** |
|
| 28 | * {@inheritdoc} |
|
| 29 | */ |
|
| 30 | public function normalize(NormalizerInterface $normalizer, $format = null, array $context = []) |
|
| 31 | { |
|
| 32 | $output = []; |
|
| 33 | if (count($this->getAll()) > 0) { |
|
| 34 | /** @var AbstractInnerHit $innerHit */ |
|
| 35 | foreach ($this->getAll() as $innerHit) { |
|
| 36 | $output[$innerHit->getName()] = $innerHit->toArray(); |
|
| 37 | } |
|
| 38 | } |
|
| 39 | ||
| 40 | return $output; |
|
| 41 | } |
|
| 42 | } |
|
| 43 | ||
| @@ 20-42 (lines=23) @@ | ||
| 17 | /** |
|
| 18 | * Search suggest dsl endpoint. |
|
| 19 | */ |
|
| 20 | class SuggestEndpoint extends AbstractSearchEndpoint |
|
| 21 | { |
|
| 22 | /** |
|
| 23 | * Endpoint name |
|
| 24 | */ |
|
| 25 | const NAME = 'suggest'; |
|
| 26 | ||
| 27 | /** |
|
| 28 | * {@inheritdoc} |
|
| 29 | */ |
|
| 30 | public function normalize(NormalizerInterface $normalizer, $format = null, array $context = []) |
|
| 31 | { |
|
| 32 | $output = []; |
|
| 33 | if (count($this->getAll()) > 0) { |
|
| 34 | /** @var TermSuggest $suggest */ |
|
| 35 | foreach ($this->getAll() as $suggest) { |
|
| 36 | $output = array_merge($output, $suggest->toArray()); |
|
| 37 | } |
|
| 38 | } |
|
| 39 | ||
| 40 | return $output; |
|
| 41 | } |
|
| 42 | } |
|
| 43 | ||