searching works now (pager missing)
[phorkie.git] / scripts / search.php
1 <?php
2 //search
3
4 namespace phorkie;
5 set_include_path(
6     __DIR__ . '/../src/'
7     . PATH_SEPARATOR . get_include_path()
8 );
9 spl_autoload_register(
10     function ($class) {
11         $file = str_replace(array('\\', '_'), '/', $class) . '.php';
12         $hdl = @fopen($file, 'r', true);
13         if ($hdl !== false) {
14             fclose($hdl);
15             require $file;
16         }
17     }
18 );
19 require_once __DIR__ . '/../data/config.default.php';
20 if (file_exists(__DIR__ . '/../data/config.php')) {
21     require_once __DIR__ . '/../data/config.php';
22 }
23 if ($GLOBALS['phorkie']['cfg']['setupcheck']) {
24     SetupCheck::run();
25 }
26
27 $r = new \HTTP_Request2(
28     'http://localhost:9200/phorkie/repo/_search',
29     \HTTP_Request2::METHOD_GET
30 );
31 $r->setBody(
32     json_encode(
33         (object)array(
34             'from' => 0,
35             'size' => 2,
36             'query' => (object)array(
37                 'bool' => (object)array(
38                     'should' => array(
39                         (object)array(
40                             'query_string' => (object)array(
41                                 'query' => 'test'
42                             ),
43                         ),
44                         (object)array(
45                             'has_child' => (object)array(
46                                 'type'         => 'file',
47                                 'query' => (object)array(
48                                     'query_string' => (object)array(
49                                         'query' => 'test'
50                                     )
51                                 )
52                             )
53                         )
54                     )
55                 ),
56             )
57         )
58     )
59 );
60 $res = $r->send();
61 echo $res->getBody() . "\n";
62 ?>