Beispiel #1
0
 public function test()
 {
     $solr = \JSolr\Search\Factory::getService();
     $response = $solr->ping();
     if ($response === false) {
         $this->setError(JText::_("COM_JSOLRSEARCH_PING_FAILED"));
         return false;
     }
     return true;
 }
Beispiel #2
0
 public function getItems($params)
 {
     $results = array();
     if (class_exists('\\JSolr\\Search\\Factory')) {
         try {
             $client = \JSolr\Search\Factory::getService();
             $query = \JSolr\Search\Factory::getQuery('*:*')->limit($params->get('count', 5))->sort($params->get('ordering', 'modified') . ' desc')->useQueryParser("edismax")->retrieveFields("*,score");
             if ($limit = $params->get('o')) {
                 $query->filters('extension:' . $limit);
             }
             if ($fq = $params->get('fq', null)) {
                 $filters = array();
                 $parts = explode(',', $fq);
                 foreach ($parts as $part) {
                     $filters[] = trim($part);
                 }
                 $query->mergeFilters($filters);
             }
             $results = $query->search();
         } catch (Exception $e) {
         }
     }
     return $results;
 }