From 9b9980477d1de9aa6f68399d27594fb39c527311 Mon Sep 17 00:00:00 2001 From: Fabian Steeg Date: Fri, 6 Sep 2024 17:42:53 +0200 Subject: [PATCH] Only switch RPPD index if count is larger than 10000 (RPB-189) --- transformAndIndexRppd.sh | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/transformAndIndexRppd.sh b/transformAndIndexRppd.sh index 23d96f6..1271792 100644 --- a/transformAndIndexRppd.sh +++ b/transformAndIndexRppd.sh @@ -9,12 +9,18 @@ cd ../rpb bash transformRppd.sh cd - sbt -Dindex.prod.name=$INDEX "runMain apps.Index baseline" -curl -X POST "weywot3:9200/_aliases?pretty" -H 'Content-Type: application/json' -d' -{ - "actions" : [ - { "remove" : { "index" : "*", "alias" : "'"$ALIAS"'" } }, - { "add" : { "index" : "'"$INDEX"'", "alias" : "'"$ALIAS"'" } } - ] -} -' -curl -S -s -o /dev/null https://rppd.lobid.org + +COUNT=$(curl -X POST "weywot3:9200/$INDEX/_count" | jq .count) +if (( $COUNT > 10000 )) ; then + curl -X POST "weywot3:9200/_aliases?pretty" -H 'Content-Type: application/json' -d' + { + "actions" : [ + { "remove" : { "index" : "*", "alias" : "'"$ALIAS"'" } }, + { "add" : { "index" : "'"$INDEX"'", "alias" : "'"$ALIAS"'" } } + ] + } + ' + curl -S -s -o /dev/null https://rppd.lobid.org +else + echo "Not switching alias, index count for $INDEX is too low: $COUNT" +fi