Made ./gendb.sh idempotent.
Now only created the index once, exit with code 1 if it exists. Resolves #23
This commit is contained in:
parent
c4b57300dd
commit
a81688ddd1
1 changed files with 9 additions and 1 deletions
10
gendb.sh
10
gendb.sh
|
@ -1,2 +1,10 @@
|
|||
#!/bin/bash
|
||||
curl -X PUT http://localhost:9200/claims -d '{ "settings" : { "number_of_shards" : 1 }, "mappings" : { "claim" : { "properties" : { "value" : { "type" : "nested" }, "suggest_name": { "type": "completion" }, "suggest_desc": { "type": "completion" } } } } }'
|
||||
if [ "$(curl -IHEAD -w '%{http_code}' 'localhost:9200/claims' -o /dev/null --connect-timeout 3 --max-time 5)" == "200" ] ;
|
||||
then
|
||||
echo "Index already exists." ;
|
||||
exit 1;
|
||||
else
|
||||
echo "Index did not exist, creating..." ;
|
||||
curl -X PUT http://localhost:9200/claims -d '{ "settings" : { "number_of_shards" : 1 }, "mappings" : { "claim" : { "properties" : { "value" : { "type" : "nested" }, "suggest_name": { "type": "completion" }, "suggest_desc": { "type": "completion" } } } } }';
|
||||
exit 0;
|
||||
fi
|
Loading…
Reference in a new issue