PHRAS-442 #time 1h

less coupling (mdarse)
This commit is contained in:
Jean-Yves Gaulier
2015-06-22 19:07:56 +02:00
parent 0584fddfc8
commit 2ee19c17f5
2 changed files with 28 additions and 17 deletions

View File

@@ -3,6 +3,8 @@
namespace Alchemy\Phrasea\SearchEngine\Elastic\Search;
use Alchemy\Phrasea\Exception\RuntimeException;
use Alchemy\Phrasea\SearchEngine\SearchEngineSuggestion;
use Doctrine\Common\Collections\ArrayCollection;
use JsonSerializable;
class FacetsResponse implements JsonSerializable
@@ -32,13 +34,20 @@ class FacetsResponse implements JsonSerializable
}
/**
* Term aggregates
*
* @return array
* @return ArrayCollection
*/
public function getFacets()
public function getAsSuggestions()
{
return $this->facets;
$suggestions = new ArrayCollection();
// for es, suggestions are a flat view of facets (api backward compatibility)
foreach ($this->facets as $facet) {
foreach ($facet['values'] as $value) {
$suggestions->add(new SearchEngineSuggestion($value['query'], $value['value'], $value['count']));
}
}
return $suggestions;
}
private function buildBucketsValues($name, $buckets)