Skip to content
Snippets Groups Projects
Commit bcc5c1d9 authored by Jérémy Destin's avatar Jérémy Destin
Browse files

Rename indexing repository. GNP-5861

parent 612f9997
No related branches found
No related tags found
1 merge request!61Fix/move indexing log in dedicate repository
......@@ -52,7 +52,7 @@ check_acknowledgment() {
local MSG=$2
echo $LOG | jq '.acknowledged? == true' | grep 'true' >/dev/null || {
echo -e "${RED}ERROR: a problem occurred when trying to ${MSG}.${NC}"
echo -e "${ORANGE}$(echo ${LOG})${NC}"
echo -e "${ORANGE}$(echo "${LOG}")${NC}"
exit 1;
}
}
......@@ -61,7 +61,7 @@ check_acknowledgment() {
MISSING_COUNT=0
PROGRAMS="gzip parallel jq"
for PROGRAM in ${PROGRAMS}; do
command -v ${PROGRAM} >/dev/null || {
command -v "${PROGRAM}" >/dev/null || {
echo -e "${ORANGE}Program ${PROGRAM} is missing, cannot continue...${NC}"
((MISSING_COUNT += 1))
}
......@@ -102,24 +102,24 @@ if [ ! -d "${DATA_DIR}" ]; then
echo -e "${RED}ERROR: Mandatory parameter 'jsonDir' is missing!${NC}"
echo && help
fi
if [ $(find ${DATA_DIR} -name "*.json" | wc -l) -le 0 ] && [ $(find ${DATA_DIR} -name "*.json.gz" | wc -l) -le 0 ]; then
if [ $(find "${DATA_DIR}" -name "*.json" | wc -l) -le 0 ] && [ $(find "${DATA_DIR}" -name "*.json.gz" | wc -l) -le 0 ]; then
echo -e "${RED}ERROR: The JSON directory ${DATA_DIR} contains no JSON files!${NC}"
echo && help
fi
[ "${DOCUMENT_TYPES}" == "all" ] && DOCUMENT_TYPES="${ALL_DOCUMENT_TYPES}"
for DOCUMENT_TYPE in ${DOCUMENT_TYPES}; do
if [ $(find ${DATA_DIR} -name "${DOCUMENT_TYPE}*.json" | wc -l) -le 0 ] && [ $(find ${DATA_DIR} -name "${DOCUMENT_TYPE}*.json.gz" | wc -l) -le 0 ]; then
if [ $(find "${DATA_DIR}" -name "${DOCUMENT_TYPE}*.json" | wc -l) -le 0 ] && [ $(find ${DATA_DIR} -name "${DOCUMENT_TYPE}*.json.gz" | wc -l) -le 0 ]; then
echo -e "${ORANGE}WARNING: The JSON directory ${DATA_DIR} contains no ${DOCUMENT_TYPE} document. Type will be ignored!${NC}"
DOCUMENT_TYPES=$(echo "${DOCUMENT_TYPES}" | sed "s/ *${DOCUMENT_TYPE} */ /g")
fi
done
# Compress JSON files
for FILE in $(find ${DATA_DIR} -name "*.json"); do
gzip $FILE
for FILE in $(find "${DATA_DIR}" -name "*.json"); do
gzip "$FILE"
done
LOG_DIR="${DATA_DIR%/}/log"
LOG_DIR="${DATA_DIR%/}/indexing-log"
if [[ -d ${LOG_DIR} ]]
then
......@@ -155,8 +155,8 @@ for DOCUMENT_TYPE in ${DOCUMENT_TYPES}; do
\"index_patterns\": [\"${INDEX_PATTERN}-*\"],
\"order\": 101,
\"mappings\":
$(cat ${BASEDIR}/../backend/src/test/resources/fr/inra/urgi/faidare/repository/es/setup/index/${DOCUMENT_TYPE}_mapping.json),
\"settings\": $(cat ${BASEDIR}/../backend/src/test/resources/fr/inra/urgi/faidare/repository/es/setup/index/settings.json)
$(cat "${BASEDIR}"/../backend/src/test/resources/fr/inra/urgi/faidare/repository/es/setup/index/${DOCUMENT_TYPE}_mapping.json),
\"settings\": $(cat "${BASEDIR}"/../backend/src/test/resources/fr/inra/urgi/faidare/repository/es/setup/index/settings.json)
}")
check_acknowledgment "${LOG}" "create template"
......@@ -170,7 +170,7 @@ for DOCUMENT_TYPE in ${DOCUMENT_TYPES}; do
echo -e "${RED}ERROR: a problem occurred when trying to index data with parallel program.${NC}"
exit $code
}
parallel "gunzip -c {} | jq '.errors' | grep -q true && echo -e '${ORANGE}ERROR found in {}${NC}' >> ${TMP_FILE} ;" ::: $(find ${DATA_DIR} -name "${DOCUMENT_TYPE}-*.log.gz")
parallel "gunzip -c {} | jq '.errors' | grep -q true && echo -e '${ORANGE}ERROR found in {}${NC}' >> ${TMP_FILE} ;" ::: $(find "${DATA_DIR}" -name "${DOCUMENT_TYPE}-*.log.gz")
if [ -f "${TMP_FILE}" ] && [ -s "${TMP_FILE}" ]; then
echo -e "${RED}ERROR: a problem occurred when trying to index data into ${ES_HOST}:${ES_PORT}/${INDEX_NAME} indice.${NC}"
echo -e "${ORANGE}$(cat ${TMP_FILE})${NC}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment