2 //index repositories in elasticsearch
7 . PATH_SEPARATOR . get_include_path()
11 $file = str_replace(array('\\', '_'), '/', $class) . '.php';
12 $hdl = @fopen($file, 'r', true);
19 require_once __DIR__ . '/../data/config.default.php';
20 if (file_exists(__DIR__ . '/../data/config.php')) {
21 require_once __DIR__ . '/../data/config.php';
23 if ($GLOBALS['phorkie']['cfg']['setupcheck']) {
28 $r = new \HTTP_Request2(
29 $GLOBALS['phorkie']['cfg']['elasticsearch'] . 'repo/_query',
30 \HTTP_Request2::METHOD_DELETE
35 'match_all' => (object)array()
40 $r = new \HTTP_Request2(
41 $GLOBALS['phorkie']['cfg']['elasticsearch'] . 'file/_query',
42 \HTTP_Request2::METHOD_DELETE
47 'match_all' => (object)array()
54 $r = new \HTTP_Request2(
55 $GLOBALS['phorkie']['cfg']['elasticsearch'] . 'file/_mapping',
56 \HTTP_Request2::METHOD_PUT
61 'file' => (object)array(
62 '_parent' => (object)array(
73 //FIXME: define schema
74 $rs = new Repositories();
75 foreach ($rs->getList(0, 10000) as $repo) {
76 $r = new \HTTP_Request2(
77 $GLOBALS['phorkie']['cfg']['elasticsearch'] . 'repo/' . $repo->id,
78 \HTTP_Request2::METHOD_PUT
84 'description' => $repo->getDescription(),
90 foreach ($repo->getFiles() as $file) {
91 $r = new \HTTP_Request2(
92 $GLOBALS['phorkie']['cfg']['elasticsearch'] . 'file/?parent=' . $repo->id,
93 \HTTP_Request2::METHOD_POST
98 'name' => $file->getFilename(),
99 'extension' => $file->getExt(),
100 'content' => $file->isText() ? $file->getContent() : '',