Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • Solr
  • SolrIndexer
  • SolrSearcherAbstract
  • SolrSearcherSimple
  • SolrSearchModule

Exceptions

  • SolrException
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
 1: <?php
 2: 
 3: /**
 4:  *
 5:  * @package Plugin
 6:  * @subpackage SearchSolr
 7:  * @author Marcus Gnaß <marcus.gnass@4fb.de>
 8:  * @copyright four for business AG
 9:  * @link http://www.4fb.de
10:  */
11: 
12: // assert CONTENIDO framework
13: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
14: 
15: /**
16:  * Simple Solr search implementation.
17:  *
18:  * This searcher is restricted on single core searches (due to the fact that
19:  * SolrQuery does not support multi core requests).
20:  *
21:  * @author Marcus Gnaß <marcus.gnass@4fb.de>
22:  */
23: class SolrSearcherSimple extends SolrSearcherAbstract {
24: 
25:     /**
26:      *
27:      * @throws cException if search cannot be performed for empty search term
28:      * @return SolrObject
29:      */
30:     public function getSearchResults() {
31: 
32:         $searchTerm = $this->_searchTerm;
33:         $searchTerm = trim($searchTerm);
34:         $searchTerm = explode(' ', $searchTerm);
35:         $searchTerm = array_map('trim', $searchTerm);
36:         $searchTerm = array_filter($searchTerm);
37: 
38:         // there are no results if there is no search term
39:         if (empty($searchTerm)) {
40:             throw new cException('search cannot be performed for empty search term');
41:         }
42: 
43:         /* SolrQuery */
44:         $query = new SolrQuery();
45:         // set the search query
46:         $query->setQuery('content:*' . implode('* *', $searchTerm) . '*');
47:         // specify the number of rows to skip
48:         $query->setStart(($this->_page - 1) * $this->_itemsPerPage);
49:         // specify the maximum number of rows to return in the result
50:         $query->setRows($this->_itemsPerPage);
51:         // specify fields to return
52:         // $query->addField('content');
53:         // $query->addField('id_art_lang');
54: 
55:         /* SolrClient */
56:         $idclient = cRegistry::getClientId();
57:         $idlang = cRegistry::getLanguageId();
58:         $options = Solr::getClientOptions($idclient, $idlang);
59:         Solr::log(print_r($options, true));
60:         $solrClient = new SolrClient($options);
61:         // $solrClient->setServlet(SolrClient::SEARCH_SERVLET_TYPE,
62:         // $this->_servlet);
63: 
64:         $results = NULL;
65:         try {
66:             $solrQueryResponse = @$solrClient->query($query);
67:             $response = $solrQueryResponse->getResponse();
68:             $response = $response->response;
69:         } catch (SolrClientException $e) {
70:             Solr::log($e, $e->getFile(), $e->getLine());
71:             Solr::log($solrClient->getDebug());
72:             Solr::log($query->toString());
73:         }
74: 
75:         return $response;
76:     }
77: 
78: }
79: 
80: 
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0