blob: 27c5c460504cd33a09d834d0a0f62f1357de6cc9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#!/usr/bin/env php
<?php
namespace phinde;
/**
* Configure the elasticsearch index.
* Throws away all data.
*/
require_once __DIR__ . '/../src/init.php';
$json = file_get_contents(__DIR__ . '/../data/elasticsearch-mapping.json');
if (json_decode($json) === null) {
echo "Error: Schema JSON is broken\n";
chdir(__DIR__ . '/../');
passthru('json_pp -t null < data/elasticsearch-mapping.json');
exit(1);
}
//delete old index
$r = new Elasticsearch_Request(
$GLOBALS['phinde']['elasticsearch'],
\HTTP_Request2::METHOD_DELETE
);
$r->allow404 = true;
$r->send();
//recreate it
$r = new Elasticsearch_Request(
$GLOBALS['phinde']['elasticsearch'],
\HTTP_Request2::METHOD_PUT
);
$r->setBody($json);
$r->send();
?>
|