diff --git a/classes/ezfezpsolrquerybuilder.php b/classes/ezfezpsolrquerybuilder.php index 142702c9..a1fa3211 100644 --- a/classes/ezfezpsolrquerybuilder.php +++ b/classes/ezfezpsolrquerybuilder.php @@ -94,7 +94,8 @@ public function buildMultiFieldQuery( $searchText, $solrFields = array(), $boost * 'searchfields', array ( 'myfield1, 'myfield2', ... ) * 'returnfields', array ( 'myfield1, 'myfield2', ... ) * 'rawfilterlist, array ( 'foreignfield:a', '(foreignfield:b AND otherfield:c)', ... ) - * ) + * ), + * 'RawFilter' => array( ) * ); * * For full facet description, see facets design document. @@ -292,6 +293,17 @@ public function buildSearch( $searchText, $params = array(), $searchTypes = arra } } + // Add per-query raw filters + // Check if raw filter parameter is indeed an array, and set it otherwise + if ( isset( $params['RawFilter']) && ! is_array( $params['RawFilter'] ) ) + { + $params['RawFilter'] = array( $params['RawFilter'] ); + } + if ( $params['RawFilter'] ) + { + $filterQuery = array_merge( $filterQuery, $params['RawFilter'] ); + } + // Build and get facet query prameters. $facetQueryParamList = $this->buildFacetQueryParamList( $params ); diff --git a/classes/ezfmodulefunctioncollection.php b/classes/ezfmodulefunctioncollection.php index be308534..dd693be2 100644 --- a/classes/ezfmodulefunctioncollection.php +++ b/classes/ezfmodulefunctioncollection.php @@ -76,13 +76,14 @@ public function getFilterParameters() * @param array list of subtree limitation node IDs * @param boolean $enableElevation Controls whether elevation should be enabled or not * @param boolean $forceElevation Controls whether elevation is forced. Applies when the srt criteria is NOT the default one ( 'score desc' ). + * @param array Raw filter parameters * * @return array Search result */ public function search( $query, $offset = 0, $limit = 10, $facets = null, $filters = null, $sortBy = null, $classID = null, $sectionID = null, $subtreeArray = null, $ignoreVisibility = null, $limitation = null, $asObjects = true, $spellCheck = null, $boostFunctions = null, $queryHandler = 'ezpublish', - $enableElevation = true, $forceElevation = false, $publishDate = null, $distributedSearch = null, $fieldsToReturn = null, $searchResultClustering = null, $extendedAttributeFilter = array() ) + $enableElevation = true, $forceElevation = false, $publishDate = null, $distributedSearch = null, $fieldsToReturn = null, $searchResultClustering = null, $extendedAttributeFilter = array(), $rawFilters = null ) { $solrSearch = new eZSolr(); $params = array( 'SearchOffset' => $offset, @@ -105,7 +106,8 @@ public function search( $query, $offset = 0, $limit = 10, $facets = null, 'DistributedSearch' => $distributedSearch, 'FieldsToReturn' => $fieldsToReturn, 'SearchResultClustering' => $searchResultClustering, - 'ExtendedAttributeFilter' => $extendedAttributeFilter ); + 'ExtendedAttributeFilter' => $extendedAttributeFilter, + 'RawFilter' => $rawFilters ); return array( 'result' => $solrSearch->search( $query, $params ) ); } diff --git a/modules/ezfind/function_definition.php b/modules/ezfind/function_definition.php index c631d10c..c10382bb 100644 --- a/modules/ezfind/function_definition.php +++ b/modules/ezfind/function_definition.php @@ -100,7 +100,11 @@ array ( 'name' => 'extended_attribute_filter', 'type' => 'array', 'required' => false, - 'default' => array() )) ); + 'default' => array() ), + array( 'name' => 'raw_filter', + 'type' => 'array', + 'required' => false, + 'default' => null ) ) ); $FunctionList['getDefaultSearchFacets'] = array( 'name' => 'getDefaultSearchFacets',