Esempio n. 1
0
 /**
  * @return SolrService
  */
 public static function get_instance()
 {
     if (self::$instance == NULL) {
         self::$instance = new SolrService();
     }
     return self::$instance;
 }
Esempio n. 2
0
 function suggest()
 {
     $this->load->library('solr/SolrService');
     $this->load->library('Search');
     // Parse term from the input
     $term = filter_input(INPUT_GET, 'term', FILTER_SANITIZE_STRING);
     $term = trim($term);
     $term = preg_replace("/^anchor (.*)/", "anchorage \$1", $term);
     $term = preg_replace("/^moor (.*)/", "mooring buoys \$1", $term);
     $term = preg_replace("/^buoy (.*)/", "mooring buoys \$1", $term);
     $term = preg_replace("/^berth (.*)/", "berthing \$1", $term);
     $term = preg_replace("/^gas (.*)/", "gas station \$1", $term);
     $keywords = ['berthing' => ["marina", "mooring", "berths", "jetty"], 'marina' => ["marina"], 'marinas' => ["marina"], 'anchorage' => ["anchorage"], 'anchorages' => ["anchorage"], 'mooring buoys' => ["buoys"], 'buoys' => ["buoys"], 'anchoring' => ["anchorage", "buoys"], 'restaurant' => ["restaurant"], 'restaurants' => ["restaurant"], 'bar' => ["bar"], 'bars' => ["bar"], 'restaurants and bars' => ["restaurant", "bar"], 'gas station' => ["gasstation"], 'gas stations' => ["gasstation"], 'supermarket' => ["supermarket"], 'supermarkets' => ["supermarket"], 'cashpoint' => ["cashpoint"], 'cashpoints' => ["cashpoint"], 'bakery' => ["bakery"], 'shopping' => ["supermarket", "minimarket"], 'shop' => ["supermarket", "minimarket"], 'shops' => ["supermarket", "minimarket"], 'beach' => ["beach"]];
     $solr = SolrService::get_instance();
     $search = new Search($solr, $keywords);
     $items = $search->do_search($term);
     echo json_encode($items);
 }
 public function search(Query $query, $offset = 0, $limit = 10)
 {
     $queryString = $query->toString();
     $response = $this->service->search($queryString, $offset, $limit);
     return new ResultSet($response, $queryString, $offset, $limit);
 }