From b45459be0560d7a01ba756c3e766e53ac0e1f7ba Mon Sep 17 00:00:00 2001 From: Lionel Walter <liowalter@gmail.com> Date: Tue, 11 Jun 2019 15:47:35 +0000 Subject: [PATCH] Enable search with solr parameter facet.contains (#1378) --- .../VuFind/src/VuFind/Search/Solr/Params.php | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/module/VuFind/src/VuFind/Search/Solr/Params.php b/module/VuFind/src/VuFind/Search/Solr/Params.php index 6ac51ee0463..8f9a07e524e 100644 --- a/module/VuFind/src/VuFind/Search/Solr/Params.php +++ b/module/VuFind/src/VuFind/Search/Solr/Params.php @@ -42,6 +42,22 @@ class Params extends \VuFind\Search\Base\Params { use \VuFind\Search\Params\FacetLimitTrait; + /** + * Search with facet.contains + * cf. https://lucene.apache.org/solr/guide/7_3/faceting.html + * + * @var string + */ + protected $facetContains = null; + + /** + * Ignore Case when using facet.contains + * cf. https://lucene.apache.org/solr/guide/7_3/faceting.html + * + * @var bool + */ + protected $facetContainsIgnoreCase = null; + /** * Offset for facet results * @@ -196,6 +212,13 @@ class Params extends \VuFind\Search\Base\Params } $facetSet['field'][] = $facetField; } + if ($this->facetContains != null) { + $facetSet['contains'] = $this->facetContains; + } + if ($this->facetContainsIgnoreCase != null) { + $facetSet['contains.ignoreCase'] + = $this->facetContainsIgnoreCase ? 'true' : 'false'; + } if ($this->facetOffset != null) { $facetSet['offset'] = $this->facetOffset; } @@ -232,6 +255,30 @@ class Params extends \VuFind\Search\Base\Params } } + /** + * Set Facet Contains + * + * @param string $p the new contains value + * + * @return void + */ + public function setFacetContains($p) + { + $this->facetContains = $p; + } + + /** + * Set Facet Contains Ignore Case + * + * @param bool $val the new boolean value + * + * @return void + */ + public function setFacetContainsIgnoreCase($val) + { + $this->facetContainsIgnoreCase = $val; + } + /** * Set Facet Offset * -- GitLab