diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2016-11-06 17:16:15 +0100 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2016-11-06 17:16:15 +0100 |
| commit | f90790c6b2a54c9b1c8a0aeaf1f23e6aa67d7aca (patch) | |
| tree | 940477fac15a001b8a5069053c0333b5eba1a2a8 | |
| parent | d9bde6ae87961c99238ba8fce0a29b81e4babb49 (diff) | |
| download | phinde-f90790c6b2a54c9b1c8a0aeaf1f23e6aa67d7aca.tar.gz phinde-f90790c6b2a54c9b1c8a0aeaf1f23e6aa67d7aca.zip | |
setup: check json before dropping current index
| -rwxr-xr-x | bin/setup.php | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/bin/setup.php b/bin/setup.php index ca71aed..27c5c46 100755 --- a/bin/setup.php +++ b/bin/setup.php @@ -7,6 +7,14 @@ namespace phinde; */ 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'], @@ -20,8 +28,6 @@ $r = new Elasticsearch_Request( $GLOBALS['phinde']['elasticsearch'], \HTTP_Request2::METHOD_PUT ); -$r->setBody( - file_get_contents(__DIR__ . '/../data/elasticsearch-mapping.json') -); +$r->setBody($json); $r->send(); ?> |
