mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-19 07:53:14 +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';
|
$collection_facet_agg['terms']['field'] = 'collection_name';
|
||||||
$aggs['Collection'] = $collection_facet_agg;
|
$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) {
|
foreach ($this->structure->getFacetFields() as $name => $field) {
|
||||||
// 2015-05-26 (mdarse) Removed databox filtering.
|
// 2015-05-26 (mdarse) Removed databox filtering.
|
||||||
// It was already done by the ACL filter in the query scope, so no
|
// 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
|
class CoreHydrator implements HydratorInterface
|
||||||
{
|
{
|
||||||
private $databox_id;
|
private $databox_id;
|
||||||
|
private $databox_name;
|
||||||
private $helper;
|
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_id = $databox_id;
|
||||||
|
$this->databox_name = $databox_name;
|
||||||
$this->helper = $helper;
|
$this->helper = $helper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,6 +43,7 @@ class CoreHydrator implements HydratorInterface
|
|||||||
$record['id'] = $this->helper->getUniqueRecordId($this->databox_id, $record['record_id']);
|
$record['id'] = $this->helper->getUniqueRecordId($this->databox_id, $record['record_id']);
|
||||||
$record['base_id'] = $this->helper->getUniqueCollectionId($this->databox_id, $record['collection_id']);
|
$record['base_id'] = $this->helper->getUniqueCollectionId($this->databox_id, $record['collection_id']);
|
||||||
$record['databox_id'] = $this->databox_id;
|
$record['databox_id'] = $this->databox_id;
|
||||||
|
$record['databox_name'] = $this->databox_name;
|
||||||
|
|
||||||
$record['record_type'] = ((int) $record['parent_record_id'] === 1)
|
$record['record_type'] = ((int) $record['parent_record_id'] === 1)
|
||||||
? SearchEngineInterface::GEM_TYPE_STORY
|
? SearchEngineInterface::GEM_TYPE_STORY
|
||||||
|
@@ -140,7 +140,7 @@ class RecordIndexer
|
|||||||
$connection = $databox->get_connection();
|
$connection = $databox->get_connection();
|
||||||
$candidateTerms = new CandidateTerms($databox);
|
$candidateTerms = new CandidateTerms($databox);
|
||||||
$fetcher = new Fetcher($connection, array(
|
$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 TitleHydrator($connection),
|
||||||
new MetadataHydrator($connection, $this->structure, $this->helper),
|
new MetadataHydrator($connection, $this->structure, $this->helper),
|
||||||
new ThesaurusHydrator($this->structure, $this->thesaurus, $candidateTerms),
|
new ThesaurusHydrator($this->structure, $this->thesaurus, $candidateTerms),
|
||||||
@@ -186,6 +186,7 @@ class RecordIndexer
|
|||||||
// Identifiers
|
// Identifiers
|
||||||
->add('record_id', 'integer') // Compound primary key
|
->add('record_id', 'integer') // Compound primary key
|
||||||
->add('databox_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('base_id', 'integer') // Unique collection ID
|
||||||
->add('collection_id', 'integer')->notIndexed() // Useless collection ID (local to databox)
|
->add('collection_id', 'integer')->notIndexed() // Useless collection ID (local to databox)
|
||||||
->add('collection_name', 'string')->notAnalyzed() // Collection name (still indexed for facets)
|
->add('collection_name', 'string')->notAnalyzed() // Collection name (still indexed for facets)
|
||||||
|
@@ -50,9 +50,18 @@ class FacetsResponse implements JsonSerializable
|
|||||||
|
|
||||||
private function buildQuery($name, $value)
|
private function buildQuery($name, $value)
|
||||||
{
|
{
|
||||||
return ($name === 'Collection') ?
|
switch($name) {
|
||||||
sprintf('collection:%s', $this->escaper->escapeWord($value)) :
|
case 'Collection':
|
||||||
sprintf('r"%s" IN %s', $this->escaper->escapeRaw($value), $name);
|
$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()
|
private function throwAggregationResponseError()
|
||||||
|
Reference in New Issue
Block a user