Closed (duplicate)
Project:
Apache Solr Search
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
15 Sep 2009 at 19:21 UTC
Updated:
13 Feb 2011 at 23:53 UTC
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
Comment #1
jpmckinney commentedComment #2
jpmckinney commentedMerged into #665714: Design a better all-purpose query builder and API