Skip to content

Instantly share code, notes, and snippets.

@mjordan
Created January 16, 2020 00:50
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjordan/16df0416a64ef95a527cb16e5d028cd5 to your computer and use it in GitHub Desktop.
Save mjordan/16df0416a64ef95a527cb16e5d028cd5 to your computer and use it in GitHub Desktop.
Shell script to get all the Solr fields indexed from MODS elements
#!/bin/bash
SOLR_HOST='http://192.168.50.111:8080'
SOLR_URL="$SOLR_HOST/solr/select?q=*:*&wt=csv&rows=0&facet&fl=mods_*"
curl -s -o mods_elements.txt "$SOLR_URL"
sed 's/,/\n/g' mods_elements.txt > mods_elements_one_per_line.txt
sed 's/_mlt$// ; s/_ms$// ; s/_mt$// ; s/_s$// ; s/_ss$// ; s/_t$// ; s/_all$// ; s/_dt$// ; s/_mdt$//' mods_elements_one_per_line.txt > mods_elements_one_per_line.txt.pruned
sort mods_elements_one_per_line.txt.pruned > mods_elements_one_per_line.txt.pruned.sorted
uniq mods_elements_one_per_line.txt.pruned.sorted > mods_elements.txt
rm mods_elements_one_per_line.txt
rm mods_elements_one_per_line.txt.pruned
rm mods_elements_one_per_line.txt.pruned.sorted
echo "The list of all unique SOLR fields indexed from MODS elements (with _x variants removed) is in mods_elements.txt. Enjoy!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment