1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10:
11:
12:
13: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
14:
15: 16: 17: 18: 19: 20: 21: 22:
23: class SolrSearcherSimple extends SolrSearcherAbstract {
24:
25: 26: 27: 28: 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:
39: if (empty($searchTerm)) {
40: throw new cException('search cannot be performed for empty search term');
41: }
42:
43:
44: $query = new SolrQuery();
45:
46: $query->setQuery('content:*' . implode('* *', $searchTerm) . '*');
47:
48: $query->setStart(($this->_page - 1) * $this->_itemsPerPage);
49:
50: $query->setRows($this->_itemsPerPage);
51:
52:
53:
54:
55:
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:
62:
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: