A search interface for data from the Politics of Patents case study (part of Copim WP6): this parses data from the archive of RTF files and provides additional data from the European Patent Office API. https://patents.copim.ac.uk
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

145 lines
5.0KB

  1. #!/bin/bash
  2. # @name: solr_import.sh
  3. # @version: 0.1
  4. # @creation_date: 2022-03-11
  5. # @license: The MIT License <https://opensource.org/licenses/MIT>
  6. # @author: Simon Bowie <ad7588@coventry.ac.uk>
  7. # @purpose: Runs imports of files into Solr indexes
  8. # @acknowledgements:
  9. # https://www.redhat.com/sysadmin/arguments-options-bash-scripts
  10. ############################################################
  11. # Subprograms #
  12. ############################################################
  13. License()
  14. {
  15. echo 'Copyright 2022 Simon Bowie <ad7588@coventry.ac.uk>'
  16. echo
  17. echo 'Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:'
  18. echo
  19. echo 'The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.'
  20. echo
  21. echo 'THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.'
  22. }
  23. Help()
  24. {
  25. # Display Help
  26. echo "This script performs Solr import functions for different cores."
  27. echo
  28. echo "Syntax: solr_import.sh [-l|h|z|a|e|i|m|p|x|d|s|w]"
  29. echo "options:"
  30. echo "l Print the MIT License notification."
  31. echo "h Print this Help."
  32. echo "z Index all."
  33. echo "a Index ACTIVE folder."
  34. echo "e Index EXPANDING folder."
  35. echo "i Index INVISIBLE folder."
  36. echo "m Index MULTI-SPECIES folder."
  37. echo "p Index PISSING & LEAKING folder."
  38. echo "x Index SECRET folder."
  39. echo "d Index SELF-DEFENDING folder."
  40. echo "s Index SURVIVING folder."
  41. echo "w Index WORKING folder."
  42. echo
  43. }
  44. Import()
  45. {
  46. docker exec -it solr bin/solr delete -c $core
  47. docker exec -it solr solr create_core -c $core -d custom
  48. #docker exec -ti --user=solr solr bash -c "cp -r /opt/solr/example/files/conf/* /var/solr/data/$core/conf/"
  49. #docker restart solr
  50. sleep 30
  51. docker run --rm -v "$directory/$location:/$core" --network=host solr:latest post -c $core /$core
  52. }
  53. Import_recursive()
  54. {
  55. docker run --rm -v "$directory/$subdirectory:/$core" --network=host solr:latest post -c $core /$core
  56. }
  57. ############################################################
  58. ############################################################
  59. # Main program #
  60. ############################################################
  61. ############################################################
  62. # Set variables
  63. directory="/Users/ad7588/projects/patent_site"
  64. # Get the options
  65. while getopts ":hlimzaespxdw" option; do
  66. case $option in
  67. l) # display License
  68. License
  69. exit;;
  70. h) # display Help
  71. Help
  72. exit;;
  73. z) # index all
  74. core="all"
  75. docker exec -it solr bin/solr delete -c $core
  76. docker exec -it solr solr create_core -c $core -d custom
  77. location="data/POP_Dataset_2022"
  78. for subdirectory in $location/*/
  79. do
  80. subdirectory=${subdirectory%*/} # remove the trailing "/"
  81. Import_recursive
  82. done
  83. exit;;
  84. a) # index ACTIVE folder
  85. core="active"
  86. location="data/pop_rtfs/ACTIVE (160)"
  87. Import
  88. exit;;
  89. e) # index EXPANDING folder
  90. core="expanding"
  91. location="data/pop_rtfs/EXPANDING (169)"
  92. Import
  93. exit;;
  94. i) # index INVISIBLE folder
  95. core="invisible"
  96. location="data/pop_rtfs/IN.VISIBLE (204)"
  97. Import
  98. exit;;
  99. m) # index MULTI-SPECIES folder
  100. core="multispecies"
  101. location="data/pop_rtfs/MULTI-SPECIES (180)"
  102. Import
  103. exit;;
  104. p) # index PISSING & LEAKING folder
  105. core="pissing"
  106. location="data/pop_rtfs/PISSING & LEAKING (168)"
  107. Import
  108. exit;;
  109. x) # index SECRET folder
  110. core="secret"
  111. location="data/pop_rtfs/SECRET (92)"
  112. Import
  113. exit;;
  114. d) # index SELF-DEFENDING folder
  115. core="defending"
  116. location="data/pop_rtfs/SELF-DEFENDING (115)"
  117. Import
  118. exit;;
  119. s) # index SURVIVING folder
  120. core="surviving"
  121. location="data/pop_rtfs/SURVIVING (166)"
  122. Import
  123. exit;;
  124. w) # index WORKING folder
  125. core="working"
  126. location="data/pop_rtfs/WORKING (101)"
  127. Import
  128. exit;;
  129. \?) # Invalid option
  130. echo "Error: Invalid option"
  131. exit;;
  132. esac
  133. done