1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13:
14: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
15:
16: 17: 18: 19: 20: 21: 22: 23:
24: class SolrSearcherSimple extends SolrSearcherAbstract {
25:
26: 27: 28: 29: 30:
31: public function getSearchResults() {
32:
33: $searchTerm = $this->_searchTerm;
34: $searchTerm = trim($searchTerm);
35: $searchTerm = explode(' ', $searchTerm);
36: $searchTerm = array_map('trim', $searchTerm);
37: $searchTerm = array_filter($searchTerm);
38:
39:
40: if (empty($searchTerm)) {
41: throw new cException('search cannot be performed for empty search term');
42: }
43:
44:
45: $query = new SolrQuery();
46:
47: $query->setQuery('content:*' . implode('* *', $searchTerm) . '*');
48:
49: $query->setStart(($this->_page - 1) * $this->_itemsPerPage);
50:
51: $query->setRows($this->_itemsPerPage);
52:
53:
54:
55:
56:
57: $idclient = cRegistry::getClientId();
58: $idlang = cRegistry::getLanguageId();
59: $options = Solr::getClientOptions($idclient, $idlang);
60: Solr::log(print_r($options, true));
61: $solrClient = new SolrClient($options);
62:
63:
64:
65: $results = NULL;
66: try {
67: $solrQueryResponse = @$solrClient->query($query);
68: $response = $solrQueryResponse->getResponse();
69: $response = $response->response;
70: } catch (SolrClientException $e) {
71: Solr::log($e, $e->getFile(), $e->getLine());
72: Solr::log($solrClient->getDebug());
73: Solr::log($query->toString());
74: }
75:
76: return $response;
77: }
78:
79: }
80:
81: