http://typo3.org/extensions/repository/view/solr/current/info/classes%25...

For example, the query class has a setFaceting method:

    /**
     * Activates and deactivates faceting for the current query.
     *
     * @param    boolean    True to enable faceting, false to disable faceting
     * @return    void
     */
    public function setFaceting($faceting = true) {
        if ($faceting) {
            $this->queryParameters['facet'] = 'true';
            $this->queryParameters['facet.mincount'] = $this->solrConfiguration['search.']['faceting.']['minimumCount'];

They also solve some of the escaping problems using the SolrPhpClient functionality, which might be a good strategy for us, too:

    public function escape($string) {
        if (!is_numeric($string)) {
            if (preg_match('/\W/', $string) == 1) {
                    // interpret as phrase, if it's not a single word
                $string = Apache_Solr_Service::escapePhrase($string);
            } else {
                $string = Apache_Solr_Service::escape($string);
            }
        }

        return $string;
    }

This I'll have to study more, but there is a method on the query that sets access groups. Don't know how instructive this is for us, but worth pondering:

    public function setUserAccessGroups(array $groups) {
        $accessFilter = array();
        foreach ($groups as $group) {
            $accessFilter[] = 'group:"' . $group . '"';
        }
        $accessFilter = implode(' OR ', $accessFilter);

        if (!in_array('-1', $groups)) {
                // if the user is logged in, don't let him find pages that
                // are "hidden at login"
            $accessFilter .= ' -group:"-1"';
        }

        $this->addFilter($accessFilter);
    }

It goes on, and basically encapsulates everything that we currently do in a procedural (and therefore very clunky) way. Good inspiration for upcoming refactoring.

Comments

jpmckinney’s picture

Version: 6.x-2.x-dev » 7.x-1.x-dev
jpmckinney’s picture

Status: Active » Closed (duplicate)