Created
November 25, 2019 10:40
-
-
Save vjrj/da1ab411404ea631f559920ade60153c to your computer and use it in GitHub Desktop.
Verification of LA data mappings in solr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Put this, for instance in /usr/loca/bin/ and adapt to your LA node | |
# | |
# Used in conjuntion with this other script: | |
# https://gist.github.com/vjrj/2b077a2bb786227a517ca03f7e30cf4c | |
# | |
# Depends on jq (apt install jq) | |
# | |
USER=XXX | |
PASS=XXX | |
INDEX=http://1.2.3.4:8983 | |
ERRORS=0 | |
drs=$1 | |
for dr in $(echo $drs | tr "," "\n") | |
do | |
NUM_REC=$(curl -s -u $USER:$PASS $INDEX/solr/biocache/select\?fl\=collection_uid\&group.field\=collection_uid\&group\=true\&indent\=on\&q\=data_resource_uid:$dr\&wt\=json | jq '.grouped.collection_uid.matches') | |
COL_UID=$(curl -s -u $USER:$PASS $INDEX/solr/biocache/select\?fl\=collection_uid\&group.field\=collection_uid\&group\=true\&indent\=on\&q\=data_resource_uid:$dr\&wt\=json | jq '.grouped.collection_uid.groups[0].groupValue' | sed 's/"//g') | |
GROUP_NUM=$(curl -s -u $USER:$PASS $INDEX/solr/biocache/select\?fl\=collection_uid\&group.field\=collection_uid\&group\=true\&indent\=on\&q\=data_resource_uid:$dr\&wt\=json | jq '.grouped.collection_uid.groups[0].doclist.numFound') | |
NUM_NULL=$(curl -g -s -u $USER:$PASS "$INDEX/solr/biocache/select?indent=on&q=data_resource_uid:$dr%20AND%20-collection_uid:[\%22\%22%20TO%20*]&wt=json" | jq '.response.numFound') | |
if [[ $COL_UID == "null" ]] | |
then | |
echo "ERROR: Incorrect collection_uid '$COL_UID' for $dr in SOLR" | |
ERRORS=$[ERRORS + 1] | |
else | |
if [[ $NUM_NULL != 0 ]] | |
then | |
echo "WARN: some collection_uid are null" | |
fi | |
if [[ $NUM_REC != $GROUP_NUM ]] | |
then | |
echo "WARN: collection_uid $COL_UID for $dr in SOLR has $GROUP_NUM records but the are other collection_uids in this dr. Total: $NUM_REC" | |
/usr/local/bin/check-mappings-in-ocurrences.sh $dr | |
else | |
echo "INFO: Correct collection_uid $COL_UID for $dr in SOLR, $NUM_REC records" | |
fi | |
fi | |
done | |
if [[ $ERRORS -gt 0 ]] | |
then | |
exit 1 | |
else | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment