3 // web interface to search
4 set_include_path(__DIR__ . '/../src/' . PATH_SEPARATOR . get_include_path());
5 require_once __DIR__ . '/../data/config.php';
6 require_once 'HTTP/Request2.php';
7 require_once 'Pager.php';
8 require_once 'Html/Pager.php';
9 require_once 'Elasticsearch.php';
10 require_once 'Elasticsearch/Request.php';
11 require_once 'functions.php';
13 if (!isset($_GET['q'])) {
19 if (isset($_GET['page'])) {
20 if (!is_numeric($_GET['page'])) {
21 throw new Exception_Input('List page is not numeric');
23 //PEAR Pager begins at 1
24 $page = (int)$_GET['page'] - 1;
26 $perPage = 10;//$GLOBALS['phinde']['perPage'];
28 $es = new Elasticsearch($GLOBALS['phinde']['elasticsearch']);
29 $res = $es->search($query, $page, $perPage);
31 $pager = new Html_Pager(
32 $res->hits->total, $perPage, $page + 1,
36 foreach ($res->hits->hits as $hit) {
38 if ($doc->title == '') {
39 $doc->title = '(no title)';
42 . '<a href="' . htmlspecialchars($doc->url) . '">'
43 . htmlspecialchars($doc->title)
45 if (isset($doc->author->name)) {
46 echo ' by <a href="' . htmlspecialchars($doc->author->url) . '">'
47 . htmlspecialchars($doc->author->name)
51 . htmlspecialchars(preg_replace('#^.*://#', '', $doc->url))
53 if (isset($doc->modate)) {
54 echo '<br/>Changed: ' . substr($doc->modate, 0, 10);
59 $links = $pager->getLinks();
61 . ' ' . implode(' ', $links['pages'])
62 . ' ' . $links['next'];
64 var_dump($res->aggregations->domain);