Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationMain
    • NavigationTop
  • 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
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
 1: <?php
 2: 
 3: /**
 4:  *
 5:  * @package Plugin
 6:  * @subpackage SearchSolr
 7:  * @version SVN Revision $Rev:$
 8:  * @author marcus.gnass
 9:  * @copyright four for business AG
10:  * @link http://www.4fb.de
11:  */
12: 
13: // assert CONTENIDO framework
14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
15: 
16: /**
17:  * Simple Solr search implementation.
18:  *
19:  * This searcher is restricted on single core searches (due to the fact that
20:  * SolrQuery does not support multi core requests).
21:  *
22:  * @author marcus.gnass
23:  */
24: class SolrSearcherSimple extends SolrSearcherAbstract {
25: 
26:     /**
27:      *
28:      * @throws cException if search cannot be performed for empty search term
29:      * @return SolrObject
30:      */
31:     public function getSearchResults() {
32: 
33:         // there are no results if there is no search term
34:         if (0 === strlen(trim($this->_searchTerm))) {
35:             throw new cException('search cannot be performed for empty search term');
36:         }
37: 
38:         /* SolrQuery */
39:         $query = new SolrQuery();
40:         // set the search query
41:         $query->setQuery('content:' . $this->_searchTerm);
42:         // specify the number of rows to skip
43:         $query->setStart(($this->_page - 1) * $this->_itemsPerPage);
44:         // specify the maximum number of rows to return in the result
45:         $query->setRows($this->_itemsPerPage);
46:         // specify fields to return
47:         // $query->addField('content');
48:         // $query->addField('id_art_lang');
49: 
50:         /* SolrClient */
51:         $options = Solr::getClientOptions();
52:         Solr::log(print_r($options, true));
53:         $solrClient = new SolrClient($options);
54:         // $solrClient->setServlet(SolrClient::SEARCH_SERVLET_TYPE,
55:         // $this->_servlet);
56: 
57:         $results = NULL;
58:         try {
59:             $solrQueryResponse = @$solrClient->query($query);
60:             $response = $solrQueryResponse->getResponse();
61:             $docs = $response->response->docs;
62:         } catch (SolrClientException $e) {
63:             Solr::log($e, $e->getFile(), $e->getLine());
64:             Solr::log($solrClient->getDebug());
65:             Solr::log($query->toString());
66:         }
67: 
68:         return $docs;
69:     }
70: 
71: }
72: 
73: 
CMS CONTENIDO 4.9.0 API documentation generated by ApiGen 2.8.0