diff --git a/Classes/Connection/Elasticsearch/Facet.php b/Classes/Connection/Elasticsearch/Facet.php index 7893f5f..e24a659 100644 --- a/Classes/Connection/Elasticsearch/Facet.php +++ b/Classes/Connection/Elasticsearch/Facet.php @@ -87,7 +87,7 @@ class Facet implements FacetInterface } foreach ($this->buckets as $bucket) { - $this->options[] = new FacetOption($bucket); + $this->options[$bucket['key']] = new FacetOption($bucket); } } } diff --git a/Classes/Connection/Elasticsearch/SearchResult.php b/Classes/Connection/Elasticsearch/SearchResult.php index f8ffdd8..486b6eb 100644 --- a/Classes/Connection/Elasticsearch/SearchResult.php +++ b/Classes/Connection/Elasticsearch/SearchResult.php @@ -140,7 +140,7 @@ class SearchResult implements SearchResultInterface } foreach ($this->result->getAggregations() as $aggregationName => $aggregation) { - $this->facets[] = $this->objectManager->get(Facet::class, $aggregationName, $aggregation); + $this->facets[$aggregationName] = $this->objectManager->get(Facet::class, $aggregationName, $aggregation); } } } diff --git a/Tests/Functional/Connection/Elasticsearch/FilterTest.php b/Tests/Functional/Connection/Elasticsearch/FilterTest.php index aa5a5dc..b5771f4 100644 --- a/Tests/Functional/Connection/Elasticsearch/FilterTest.php +++ b/Tests/Functional/Connection/Elasticsearch/FilterTest.php @@ -78,16 +78,16 @@ class FilterTest extends AbstractFunctionalTestCase $this->assertSame(1, count($result->getFacets()), 'Did not receive the single defined facet.'); - $facet = $result->getFacets()[0]; + $facet = current($result->getFacets()); $this->assertSame('contentTypes', $facet->getName(), 'Name of facet was not as expected.'); $this->assertSame('CType', $facet->getField(), 'Field of facet was not expected.'); $options = $facet->getOptions(); $this->assertSame(2, count($options), 'Did not receive the expected number of possible options for facet.'); - $option = $options[0]; + $option = $options['HTML']; $this->assertSame('HTML', $option->getName(), 'Option did not have expected Name.'); $this->assertSame(1, $option->getCount(), 'Option did not have expected count.'); - $option = $options[1]; + $option = $options['Header']; $this->assertSame('Header', $option->getName(), 'Option did not have expected Name.'); $this->assertSame(1, $option->getCount(), 'Option did not have expected count.'); }