The Gitlab instance will be restarted on Monday April 28th at 2AM. There will be a short interruption of service.

Skip to content
Snippets Groups Projects
Commit 529f7bb2 authored by Demian Katz's avatar Demian Katz
Browse files

Added facet_limit_by_field support for Summon.

parent 14914386
No related merge requests found
...@@ -122,7 +122,7 @@ queryExpansion:true = include_synonyms ...@@ -122,7 +122,7 @@ queryExpansion:true = include_synonyms
; ;
; The name of the index field may optionally be followed by comma-separated ; The name of the index field may optionally be followed by comma-separated
; parameters (i.e. ",or,1,15") as defined by the Summon API. Any provided ; parameters (i.e. ",or,1,15") as defined by the Summon API. Any provided
; parameters will override defaults like the facet_limit setting in ; parameters will override defaults like the facet_limit* settings in
; [Facet_Settings] below. ; [Facet_Settings] below.
[Facets] [Facets]
Library = Location Library = Location
...@@ -159,7 +159,10 @@ top_cols = 3 ...@@ -159,7 +159,10 @@ top_cols = 3
; These settings affect the way the facets are displayed ; These settings affect the way the facets are displayed
[Facet_Settings] [Facet_Settings]
facet_limit = 30 ; how many values should we show for each facet? ; By default, how many values should we show for each facet?
facet_limit = 30
; Override facet_limit on a per-field basis using this array:
;facet_limit_by_field[ContentType] = 50
; These facets will be displayed as limiters on the advanced screen ; These facets will be displayed as limiters on the advanced screen
[Advanced_Facets] [Advanced_Facets]
......
...@@ -200,6 +200,8 @@ class Params extends \VuFind\Search\Base\Params ...@@ -200,6 +200,8 @@ class Params extends \VuFind\Search\Base\Params
$config = $this->getServiceLocator()->get('VuFind\Config')->get('Summon'); $config = $this->getServiceLocator()->get('VuFind\Config')->get('Summon');
$defaultFacetLimit = isset($config->Facet_Settings->facet_limit) $defaultFacetLimit = isset($config->Facet_Settings->facet_limit)
? $config->Facet_Settings->facet_limit : 30; ? $config->Facet_Settings->facet_limit : 30;
$fieldSpecificLimits = isset($config->Facet_Settings->facet_limit_by_field)
? $config->Facet_Settings->facet_limit_by_field : null;
$finalFacets = []; $finalFacets = [];
foreach ($this->getFullFacetSettings() as $facet) { foreach ($this->getFullFacetSettings() as $facet) {
...@@ -207,10 +209,12 @@ class Params extends \VuFind\Search\Base\Params ...@@ -207,10 +209,12 @@ class Params extends \VuFind\Search\Base\Params
// if not, override them with defaults. // if not, override them with defaults.
$parts = explode(',', $facet); $parts = explode(',', $facet);
$facetName = $parts[0]; $facetName = $parts[0];
$bestDefaultFacetLimit = isset($fieldSpecificLimits->$facetName)
? $fieldSpecificLimits->$facetName : $defaultFacetLimit;
$defaultMode = ($this->getFacetOperator($facet) == 'OR') ? 'or' : 'and'; $defaultMode = ($this->getFacetOperator($facet) == 'OR') ? 'or' : 'and';
$facetMode = isset($parts[1]) ? $parts[1] : $defaultMode; $facetMode = isset($parts[1]) ? $parts[1] : $defaultMode;
$facetPage = isset($parts[2]) ? $parts[2] : 1; $facetPage = isset($parts[2]) ? $parts[2] : 1;
$facetLimit = isset($parts[3]) ? $parts[3] : $defaultFacetLimit; $facetLimit = isset($parts[3]) ? $parts[3] : $bestDefaultFacetLimit;
$facetParams = "{$facetMode},{$facetPage},{$facetLimit}"; $facetParams = "{$facetMode},{$facetPage},{$facetLimit}";
$finalFacets[] = "{$facetName},{$facetParams}"; $finalFacets[] = "{$facetName},{$facetParams}";
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment