clarify that we support two ways to embed pastes
[phorkie.git] / scripts / search.php
1 <?php
2 //search
3
4 namespace phorkie;
5 require_once __DIR__ . '/../src/phorkie/autoload.php';
6 require_once __DIR__ . '/../data/config.default.php';
7 if (file_exists(__DIR__ . '/../data/config.php')) {
8     require_once __DIR__ . '/../data/config.php';
9 }
10 if ($GLOBALS['phorkie']['cfg']['setupcheck']) {
11     SetupCheck::run();
12 }
13
14 $r = new Database_Adapter_Elasticsearch_HTTPRequest(
15     $GLOBALS['phorkie']['cfg']['elasticsearch'] . 'repo/_search',
16     \HTTP_Request2::METHOD_GET
17 );
18 $r->setBody(
19     json_encode(
20         (object)array(
21             'from' => 0,
22             'size' => 2,
23             'query' => (object)array(
24                 'bool' => (object)array(
25                     'should' => array(
26                         (object)array(
27                             'query_string' => (object)array(
28                                 'query' => 'test'
29                             ),
30                         ),
31                         (object)array(
32                             'has_child' => (object)array(
33                                 'type'         => 'file',
34                                 'query' => (object)array(
35                                     'query_string' => (object)array(
36                                         'query' => 'test'
37                                     )
38                                 )
39                             )
40                         )
41                     )
42                 ),
43             )
44         )
45     )
46 );
47 $res = $r->send();
48 echo $res->getBody() . "\n";
49 ?>