mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
Merge pull request #1409 from jygaulier/PHRAS-454_FACETTES-BASES
Phras 454 facettes bases
This commit is contained in:
@@ -378,6 +378,11 @@ class ElasticSearchEngine implements SearchEngineInterface
|
||||
$collection_facet_agg['terms']['field'] = 'collection_name';
|
||||
$aggs['Collection'] = $collection_facet_agg;
|
||||
|
||||
// We always want a base facet right now
|
||||
$base_facet_agg = array();
|
||||
$base_facet_agg['terms']['field'] = 'databox_name';
|
||||
$aggs['Base'] = $base_facet_agg;
|
||||
|
||||
foreach ($this->structure->getFacetFields() as $name => $field) {
|
||||
// 2015-05-26 (mdarse) Removed databox filtering.
|
||||
// It was already done by the ACL filter in the query scope, so no
|
||||
|
@@ -17,11 +17,13 @@ use Alchemy\Phrasea\SearchEngine\SearchEngineInterface;
|
||||
class CoreHydrator implements HydratorInterface
|
||||
{
|
||||
private $databox_id;
|
||||
private $databox_name;
|
||||
private $helper;
|
||||
|
||||
public function __construct($databox_id, RecordHelper $helper)
|
||||
public function __construct($databox_id, $databox_name, RecordHelper $helper)
|
||||
{
|
||||
$this->databox_id = $databox_id;
|
||||
$this->databox_name = $databox_name;
|
||||
$this->helper = $helper;
|
||||
}
|
||||
|
||||
@@ -41,6 +43,7 @@ class CoreHydrator implements HydratorInterface
|
||||
$record['id'] = $this->helper->getUniqueRecordId($this->databox_id, $record['record_id']);
|
||||
$record['base_id'] = $this->helper->getUniqueCollectionId($this->databox_id, $record['collection_id']);
|
||||
$record['databox_id'] = $this->databox_id;
|
||||
$record['databox_name'] = $this->databox_name;
|
||||
|
||||
$record['record_type'] = ((int) $record['parent_record_id'] === 1)
|
||||
? SearchEngineInterface::GEM_TYPE_STORY
|
||||
|
@@ -140,7 +140,7 @@ class RecordIndexer
|
||||
$connection = $databox->get_connection();
|
||||
$candidateTerms = new CandidateTerms($databox);
|
||||
$fetcher = new Fetcher($connection, array(
|
||||
new CoreHydrator($databox->get_sbas_id(), $this->helper),
|
||||
new CoreHydrator($databox->get_sbas_id(), $databox->get_viewname(), $this->helper),
|
||||
new TitleHydrator($connection),
|
||||
new MetadataHydrator($connection, $this->structure, $this->helper),
|
||||
new ThesaurusHydrator($this->structure, $this->thesaurus, $candidateTerms),
|
||||
@@ -186,6 +186,7 @@ class RecordIndexer
|
||||
// Identifiers
|
||||
->add('record_id', 'integer') // Compound primary key
|
||||
->add('databox_id', 'integer') // Compound primary key
|
||||
->add('databox_name', 'string')->notAnalyzed() // database name (still indexed for facets)
|
||||
->add('base_id', 'integer') // Unique collection ID
|
||||
->add('collection_id', 'integer')->notIndexed() // Useless collection ID (local to databox)
|
||||
->add('collection_name', 'string')->notAnalyzed() // Collection name (still indexed for facets)
|
||||
|
@@ -50,9 +50,18 @@ class FacetsResponse implements JsonSerializable
|
||||
|
||||
private function buildQuery($name, $value)
|
||||
{
|
||||
return ($name === 'Collection') ?
|
||||
sprintf('collection:%s', $this->escaper->escapeWord($value)) :
|
||||
sprintf('r"%s" IN %s', $this->escaper->escapeRaw($value), $name);
|
||||
switch($name) {
|
||||
case 'Collection':
|
||||
$r = sprintf('collection:%s', $this->escaper->escapeWord($value));
|
||||
break;
|
||||
case "Base":
|
||||
$r = sprintf('base:%s', $this->escaper->escapeWord($value));
|
||||
break;
|
||||
default:
|
||||
$r = sprintf('r"%s" IN %s', $this->escaper->escapeRaw($value), $name);
|
||||
break;
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
private function throwAggregationResponseError()
|
||||
|
Reference in New Issue
Block a user