From 100c777fa34eaae982dbbb87dd49287c808507e7 Mon Sep 17 00:00:00 2001 From: jdestin <jeremy.destin@inra.fr> Date: Mon, 4 May 2020 14:55:58 +0200 Subject: [PATCH 1/2] Fix: Correct the bug of could not list group ids --- scripts/harvest.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/harvest.sh b/scripts/harvest.sh index 3d5504d1..b1b1dad4 100755 --- a/scripts/harvest.sh +++ b/scripts/harvest.sh @@ -122,7 +122,7 @@ done for DOCUMENT_TYPE in ${DOCUMENT_TYPES}; do echo && echo -e "${BOLD}Manage ${DOCUMENT_TYPE} documents...${NC}" INDEX_PATTERN=$(echo "faidare_${DOCUMENT_TYPE}_${ENV}" | sed -E "s/([a-z])([A-Z])/\1-\2/" | tr '[:upper:]' '[:lower:]') - + # Create template TEMPLATE_NAME="${INDEX_PATTERN}_template" echo -e "* Create setting/mapping template ${TEMPLATE_NAME}..." @@ -173,7 +173,9 @@ for DOCUMENT_TYPE in ${DOCUMENT_TYPES}; do echo -e "${ORANGE}Expected ${COUNT_EXTRACTED_DOCS} documents but got ${COUNT_INDEXED_DOCS} indexed documents.${NC}" exit 1; fi - + # Wait util the index is created + sleep 10 + # Add aliases ALIAS_PATTERN="${INDEX_PATTERN}-group*" ALIAS_EXIST=$(curl -s -XGET "${ES_HOST}:${ES_PORT}/_alias/${ALIAS_PATTERN}" | jq '.status' | grep -q "404" && echo "false" || echo "true") @@ -182,7 +184,7 @@ for DOCUMENT_TYPE in ${DOCUMENT_TYPES}; do LOG=$(curl -s -XDELETE "${ES_HOST}:${ES_PORT}/*/_aliases/${ALIAS_PATTERN}") check_acknowledgment "${LOG}" "delete aliases" fi - + echo -e "* List groupId from ${INDEX_NAME} (to create filtered aliases)..." GROUP_IDS=$(curl -s -H 'Content-Type: application/json' -XGET "${ES_HOST}:${ES_PORT}/${INDEX_NAME}/_search" -d' { @@ -224,7 +226,7 @@ for DOCUMENT_TYPE in ${DOCUMENT_TYPES}; do }") check_acknowledgment "${LOG}" "create aliase" done - + # Delete all but last created indices (thanks to the timestamp suffix) echo -e "* Delete old indices ${INDEX_PATTERN} (to avoid accumulation over time):" OLD_INDICES=$(curl -sf -XGET "${ES_HOST}:${ES_PORT}/_cat/indices/${INDEX_PATTERN}*?h=index" | sort | head -n -1) -- GitLab From 5a4fe8f2540ee6347e8049ff31329751cd4da499 Mon Sep 17 00:00:00 2001 From: Dorothee Charruaud <dorothee.charruaud@inra.fr> Date: Mon, 4 May 2020 15:56:55 +0200 Subject: [PATCH 2/2] Apply suggestion to scripts/harvest.sh --- scripts/harvest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/harvest.sh b/scripts/harvest.sh index b1b1dad4..4b0bec1a 100755 --- a/scripts/harvest.sh +++ b/scripts/harvest.sh @@ -173,7 +173,7 @@ for DOCUMENT_TYPE in ${DOCUMENT_TYPES}; do echo -e "${ORANGE}Expected ${COUNT_EXTRACTED_DOCS} documents but got ${COUNT_INDEXED_DOCS} indexed documents.${NC}" exit 1; fi - # Wait util the index is created + # Wait util the index is created. Prevents "group_id" not found during the alias creation step sleep 10 # Add aliases -- GitLab