示例#1
0
 public function testSearch()
 {
     $account = Account::login("searchzen.org", "test");
     $collection = $account->collections[0];
     $searcher = new Searcher($collection);
     $results = $searcher->search("Jacob", 0);
 }
示例#2
0
 public function actionList($status, $flags, $q)
 {
     if ($status) {
         $this->songy = $this->songList->findByStatus($status);
     } else {
         $this->songy = $this->songList->findAll();
     }
     //Simple song searching
     if ($q) {
         $searcher = new \Searcher();
         $searcher->setModel($this->songy);
         $searcher->setMask("%?%");
         $searcher->setColumns(array("name", "interpret_name"));
         $searcher->search($q);
         $this->template->q = $q;
     }
     //Filtering by flags
     if ($flags) {
         $this->setFilterDefaults($flags);
         $filter = new \FlagFilter();
         $filter->setModel($this->songy);
         $filter->setFlags(array("r" => "remix", "i" => "instro", "p" => "pecka", "w" => "wishlist_only", "n" => array("column" => "note", "by" => " != ''")));
         $filter->filter($flags);
     }
     //Store list page and filtering
     $this->getSession()->getSection("SongList")->listing = $this->getHttpRequest()->getQuery();
     $this->template->summary = $this->songList->getSummary();
     $this->template->status = $status;
 }
 public function shop(Shop $shop)
 {
     $this->setBasicQuery();
     Session::put('shop_name', $shop->shop_name);
     $searcher = new Searcher($this->query);
     $oldValues = $searcher->getOldValues();
     $suscriptions = $searcher->getQuery()->orderBy('vouchers.finishes_at', Session::get('orderBy'))->paginate($this->resultsPerPage);
     return View::make('backoffice.shop')->with('suscriptions', $suscriptions)->with('shop', $shop)->with('oldValues', $oldValues);
 }
示例#4
0
 public function join(Searcher $s)
 {
     $st = $s->table();
     $rMap = array_flip($s->relationMap());
     $refKey = $rMap[$this->table];
     $this->conds[$st . ".{$refKey}={$this->table}.id"] = null;
     $this->conds += $s->conds;
     if (!in_array($st, $this->tables)) {
         $this->tables[] = $st;
     }
     return $this;
 }
 function do_search($wp_query)
 {
     if (!$wp_query->is_main_query() || is_admin() || $this->attempted) {
         return;
     }
     $this->attempted = true;
     $args = $this->facets($wp_query, isset($_GET['es']) ? $_GET['es'] : array());
     if ($args === null) {
         return;
     }
     $this->page = isset($wp_query->query_vars['paged']) && $wp_query->query_vars['paged'] > 0 ? $wp_query->query_vars['paged'] - 1 : 0;
     if (!isset($wp_query->query_vars['posts_per_page'])) {
         $wp_query->query_vars['posts_per_page'] = get_option('posts_per_page');
     }
     $this->search = isset($wp_query->query_vars['s']) ? urldecode(str_replace('\\"', '"', $wp_query->query_vars['s'])) : '';
     $results = Searcher::search($this->search, $this->page, $wp_query->query_vars['posts_per_page'], $args, $this->search ? false : true);
     if ($results == null) {
         return null;
     }
     $this->total = $results['total'];
     $this->ids = $results['ids'];
     $wp_query->query_vars['s'] = '';
     # do not show results if none were returned
     $wp_query->query_vars['post__in'] = empty($results['ids']) ? array(0) : $results['ids'];
     $wp_query->query_vars['paged'] = 1;
     $wp_query->facets = $results['facets'];
     $this->searched = true;
 }
示例#6
0
 public static function getInstance(array $_post)
 {
     if (!isset(self::$instance)) {
         self::$instance = new Searcher($_post);
     }
     return self::$instance;
 }
示例#7
0
 public static function S($key, $searcher = 'baidu', $num = 10, $page = 1)
 {
     if (!self::$s instanceof self) {
         self::$s = new self();
     }
     self::$s->query($key, $searcher, $num, $page);
     return self::$s;
 }
 public function startSearchQuery()
 {
     if (isset($_POST['search'])) {
         $db = Db::getInstance();
         $db->connect();
         $_POST = Db::getInstance()->escape($_POST);
         $searcher = Searcher::getInstance($_POST);
         $searcher->setQuery();
         $searcher->getQuery();
     } elseif (isset($_POST['reset'])) {
         $_POST = array();
         $searcher = Searcher::getInstance($_POST);
         $searcher->setQuery();
         $searcher->getQuery();
     } else {
         return false;
     }
     return $searcher->getQuery();
 }
 public function testParseResponse()
 {
     $searcher = new Searcher();
     $data = array('hits' => array('total' => 100, 'hits' => array(array('_score' => 5, '_id' => 1), array('_score' => 2, '_id' => 10), array('_score' => 3, '_id' => 100))), 'facets' => array('name1' => array('terms' => array(array('term' => 'term1', 'count' => 10), array('term' => 'term2', 'count' => 15))), 'range1' => array('ranges' => array(array('from' => 0, 'to' => 10, 'count' => 15), array('from' => 10, 'to' => 20, 'count' => 20)))));
     $response = new \Elastica\Response(json_encode($data));
     $results = new \Elastica\ResultSet($response, new \Elastica\Query());
     $output = $searcher->_parseResults($results);
     $this->assertEquals(array('total' => 100, 'facets' => array('name1' => array('term1' => 10, 'term2' => 15), 'range1' => array('0-10' => 15, '10-20' => 20)), 'ids' => array(1, 10, 100)), $output);
 }
    public $data = [];
    public function run()
    {
        echo 'Running ' . $this->getStacked() . ' jobs' . PHP_EOL;
    }
    /**
     * To avoid corrupting the array here
     * we use array_merge here instead of just
     * $this->data[] = $html
     *
     * @param string $data
     */
    public function addData($data)
    {
        $this->data = array_merge($this->data, [$data]);
    }
}
// Stack our jobs on our worker
$worker = new Searcher();
$searches = ['dogs', 'cats', 'birds'];
foreach ($searches as $key => &$search) {
    $search = new SearchGoogle($search);
    $worker->stack($search);
}
// Start all jobs
$worker->start();
// Join all jobs and close worker
$worker->shutdown();
foreach ($worker->data as $html) {
    echo substr($html, 0, 20) . PHP_EOL;
}
示例#11
0
文件: YASE.php 项目: vichingo/yase
 public function search($domain, $query)
 {
     $searcher = new Searcher($this->getAccountId($domain));
     return $searcher->search($query, 0);
 }
示例#12
0
    list($results, $total_results, $time) = Searcher::getLatest($category, $days, $minsize, $page, RPP);
    $total_pages = ceil($total_results / RPP);
    if ($total_pages > 1) {
        $pagination = array_fill(1, $total_pages, array('selected' => false, 'category' => urlencode($category), 'days' => urlencode($days), 'minsize' => urlencode($minsize)));
        $pagination[$page]['selected'] = true;
        $tpl_values['pagination'] = true;
        $tpl_values['pagination_viewlast'] = $pagination;
        if ($page > 1) {
            if ($page == 2) {
                $tpl_values['prevlink'] = '?cat=' . urlencode($category) . '&d=' . $days . '&minsize=' . urlencode($minsize);
            } else {
                $tpl_values['prevlink'] = '?p=' . ($page - 1) . '&cat=' . urlencode($category) . '&d=' . $days . '&minsize=' . urlencode($minsize);
            }
        }
        if ($page < $total_pages) {
            $tpl_values['nextlink'] = '?p=' . ($page + 1) . '&cat=' . urlencode($category) . '&d=' . $days . '&minsize=' . urlencode($minsize);
        }
    }
    if (!count($results)) {
        $tpl_values['nofound'] = true;
    }
    $tpl_values['results'] = $results;
    $tpl_values['time'] = $time;
    $tpl_values['powered_mysql'] = true;
    $tpl_values['latest_form'] = true;
} else {
    $tpl_values['normal_form'] = true;
    $tpl_values['viewlast_categories'] = Searcher::getCategories();
}
$T->set($tpl_values);
echo $T->parse();
示例#13
0
 public function testSearcher()
 {
     $girl = new PettyGirl('Sufei');
     $searcher = new Searcher($girl);
     $searcher->show();
 }
示例#14
0
                $match = true;
                break;
            }
        }
        if (!$match) {
            die;
        }
        if ($this->name == '') {
            $this->name = '%';
        }
        $this->pos = 0;
        $this->num = 0;
    }
}
// main
$searcher = new Searcher();
$input = new Input();
$output = null;
$count = 0;
try {
    $searcher->setInput($input);
    $db = OnyokuDB::getInstance();
    if ($count = $searcher->count($db)) {
        // ヒットした件数
        $searcher->search($db);
    }
    $output = $searcher->export();
} catch (Exception $e) {
    $error_message = $e->getMessage();
}
$result['results'] = $count;
示例#15
0
 public function autocomplete_callback()
 {
     $query = sanitize_text_field($_GET['query']);
     require_once "lib" . DIRECTORY_SEPARATOR . "Searcher.php";
     $searcher = new Searcher(get_option('elasticsearch_settings_server'));
     $searcher->auto_complete_query($query, get_option('elasticsearch_settings_index_name'));
     die;
 }
<?php

require_once __DIR__ . "/../class/Searcher.class.php";
header('Content-Type: text/html; charset=utf-8');
if (isset($_GET)) {
    $Searcher = new Searcher($_GET['keyword']);
    $Searcher->buildSmallResult();
    echo $Searcher->getResult();
}
示例#17
0
<?php

require "elastic.php";
require "indexer.php";
require "searcher.php";
$indexer = new Indexer();
$indexer->setIndex("test")->setType("type");
echo "Add\n";
print_r($indexer->add(array("name" => 'asd', "phone" => "79111234567")));
print_r($indexer->add(array("name" => 'test asd', "phone" => "79133234567")));
print_r($indexer->add(array("name" => 'test', "phone" => "79155234567")));
$client = new Elastic();
echo "Get\n";
print_r($client->get(array('index' => 'test', 'type' => 'type', 'id' => 1)));
$searcher = new Searcher();
$searcher->setIndex("test")->setType("type");
echo "Search\n";
print_r($searcher->partial_query(array("name" => "te", 'phone' => '7913')));
// print_r($searcher->query_string('test +79155234*'));
echo "Clear index\n";
//print_r($indexer->clear());
<?php

require_once __DIR__ . "/../class/Searcher.class.php";
header('Content-Type: text/html; charset=utf-8');
if (isset($_GET)) {
    $Searcher = new Searcher($_GET['keyword']);
    $Searcher->buildFullResult();
    echo $Searcher->getResult();
}