Пример #1
0
 public function searchAction()
 {
     if ($_GET['type'] == 'name') {
         return $this->redirect('/name/' . urlencode($_GET['q']));
     }
     if ($_GET['type'] == 'fund') {
         return $this->redirect('/fund/' . urlencode($_GET['q']));
     }
     if (preg_match('#\\d{8}#', $_GET['q'])) {
         return $this->redirect('/id/' . $_GET['q']);
     }
     $page = intval($_GET['page']) ?: 1;
     if (preg_match('#^address:(.*)$#', $_GET['q'], $matches)) {
         $ret = SearchLib::searchCompaniesByAddress($matches[1], $page);
     } else {
         $ret = SearchLib::searchCompaniesByName($_GET['q'], $page);
     }
     if ($ret->hits->total == 1) {
         return $this->redirect('/id/' . urlencode($ret->hits->hits[0]->_id));
     }
     $this->view->page = $page;
     $this->view->max_page = ceil($ret->hits->total / 10);
     $this->view->search_word = $_GET['q'];
     $this->view->search_result = $ret;
 }
Пример #2
0
 public function searchAction()
 {
     $page = intval($_GET['page']) ?: 1;
     $alive_only = $_GET['alive_only'] ? true : false;
     $search_ret = SearchLib::searchCompaniesByName($_GET['q'], $page, $alive_only);
     $ret = new StdClass();
     $data = array();
     foreach ($search_ret->hits->hits as $hit) {
         $hit->_source->{'統一編號'} = $hit->_id;
         $data[] = $hit->_source;
     }
     $ret->data = $data;
     $ret->found = $search_ret->hits->total;
     return $this->jsonp($ret, strval($_GET['callback']));
 }
Пример #3
0
<?php

include __DIR__ . '/../init.inc.php';
$fp = fopen(__DIR__ . '/../maps/rare-word.csv', 'r');
$words = array();
while ($rows = fgetcsv($fp)) {
    list($old, $new) = $rows;
    $words[$old] = $new;
    for ($i = 0; true; $i++) {
        $ret = SearchLib::searchCompaniesByName($old, $i + 1);
        foreach ($ret->hits->hits as $hit) {
            Unit::find($hit->_id)->updateSearch();
        }
        $total = $ret->hits->total;
        if ($i * 10 >= $total) {
            break;
        }
    }
}
fclose($fp);