d7d1b643ee1b537c608e8cef629d0cd6b54f4c54
[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         if (stream_resolve_include_path($file)) {
13             require $file;
14         }
15     }
16 );
17 require_once __DIR__ . '/../data/config.default.php';
18 if (file_exists(__DIR__ . '/../data/config.php')) {
19     require_once __DIR__ . '/../data/config.php';
20 }
21 if ($GLOBALS['phorkie']['cfg']['setupcheck']) {
22     SetupCheck::run();
23 }
24
25 $r = new Database_Adapter_Elasticsearch_HTTPRequest(
26     $GLOBALS['phorkie']['cfg']['elasticsearch'] . 'repo/_search',
27     \HTTP_Request2::METHOD_GET
28 );
29 $r->setBody(
30     json_encode(
31         (object)array(
32             'from' => 0,
33             'size' => 2,
34             'query' => (object)array(
35                 'bool' => (object)array(
36                     'should' => array(
37                         (object)array(
38                             'query_string' => (object)array(
39                                 'query' => 'test'
40                             ),
41                         ),
42                         (object)array(
43                             'has_child' => (object)array(
44                                 'type'         => 'file',
45                                 'query' => (object)array(
46                                     'query_string' => (object)array(
47                                         'query' => 'test'
48                                     )
49                                 )
50                             )
51                         )
52                     )
53                 ),
54             )
55         )
56     )
57 );
58 $res = $r->send();
59 echo $res->getBody() . "\n";
60 ?>