b6273b457dd8fbb4ed9fa091678ac528af8c0b2d
[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 //delete all repos
28 $r = new \HTTP_Request2(
29     'http://localhost:9200/phorkie/repo/_search',
30     \HTTP_Request2::METHOD_GET
31 );
32 $r->setBody(
33     json_encode(
34         (object)array(
35             'query' => (object)array(
36                 'bool' => (object)array(
37                     'should' => array(
38                         (object)array(
39                             'query_string' => (object)array(
40                                 'query' => 'test'
41                             ),
42                         ),
43                         (object)array(
44                             'has_child' => (object)array(
45                                 'type'         => 'file',
46                                 'query' => (object)array(
47                                     'query_string' => (object)array(
48                                         'query' => 'test'
49                                     )
50                                 )
51                             )
52                         )
53                     )
54                 ),
55             )
56         )
57     )
58 );
59 $res = $r->send();
60 echo $res->getBody() . "\n";
61 ?>