[TYPO3-Solr] Hierarchical facets decodeFilter

devweb dev-si at cndp.fr
Thu Jun 8 11:34:37 CEST 2017


this is the new code (6.1.0):
    /**
     * Parses the given hierarchy filter and returns a Solr filter query.
     *
     * @param string $hierarchy The hierarchy filter query.
     * @param array $configuration Facet configuration
     * @return string Lucene query language filter to be used for querying Solr
     */
    public function decodeFilter($hierarchy, array $configuration = [])
    {
        $hierarchy = substr($hierarchy, 1);
        $hierarchy = rtrim($hierarchy, '/');
        $hierarchyItems = explode(self::DELIMITER, $hierarchy);

        $hierarchyFilter = '"' . (count($hierarchyItems) - 1) . '-' . $hierarchy . '/"';

        return $hierarchyFilter;
    }

and this is the old code :
       /**
	 * Parses the given hierarchy filter and returns a Solr filter query.
	 *
	 * @param string $hierarchy The hierarchy filter query.
	 * @param array $configuration Facet configuration
	 * @return string Lucene query language filter to be used for querying Solr
	 */
	public function decodeFilter($hierarchy, array $configuration = array()) {
		$hierarchy      = substr($hierarchy, 1);
		$hierarchyItems = explode(self::DELIMITER, $hierarchy);

		$hierarchyFilter = '"' . (count($hierarchyItems) - 1) . '-' . $hierarchy . '"';

		return $hierarchyFilter;
	}



More information about the TYPO3-project-solr mailing list