A search interface for the Performing Patents Otherwise publication as part of 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 OPS API. https://patents.copim.ac.uk
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

146 lines
5.1KB

  1. #!/bin/bash
  2. # @name: solr_import.sh
  3. # @creation_date: 2022-03-11
  4. # @license: The MIT License <https://opensource.org/licenses/MIT>
  5. # @author: Simon Bowie <ad7588@coventry.ac.uk>
  6. # @purpose: Runs imports of files into Solr indexes
  7. # @acknowledgements:
  8. # https://www.redhat.com/sysadmin/arguments-options-bash-scripts
  9. ############################################################
  10. # Subprograms #
  11. ############################################################
  12. License()
  13. {
  14. echo 'Copyright 2022 Simon Bowie <ad7588@coventry.ac.uk>'
  15. echo
  16. 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:'
  17. echo
  18. echo 'The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.'
  19. echo
  20. 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.'
  21. }
  22. Help()
  23. {
  24. # Display Help
  25. echo "This script performs Solr import functions for different cores."
  26. echo
  27. echo "Syntax: solr_import.sh [-l|h|z|a|e|i|m|p|x|d|s|w]"
  28. echo "options:"
  29. echo "l Print the MIT License notification."
  30. echo "h Print this Help."
  31. echo "z Index all."
  32. echo "a Index ACTIVE folder."
  33. echo "e Index EXPANDING folder."
  34. echo "i Index INVISIBLE folder."
  35. echo "m Index MULTI-SPECIES folder."
  36. echo "p Index PISSING & LEAKING folder."
  37. echo "x Index SECRET folder."
  38. echo "d Index SELF-DEFENDING folder."
  39. echo "s Index SURVIVING folder."
  40. echo "w Index WORKING folder."
  41. echo
  42. }
  43. Import()
  44. {
  45. docker exec -it solr bin/solr delete -c $core
  46. #docker exec -it solr solr create_core -c $core -d custom
  47. docker exec -it solr solr create_core -c $core
  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_python"
  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. docker exec -it solr solr create_core -c $core
  78. location="data/POP_Dataset_2022"
  79. for subdirectory in $location/*/
  80. do
  81. subdirectory=${subdirectory%*/} # remove the trailing "/"
  82. Import_recursive
  83. done
  84. exit;;
  85. a) # index ACTIVE folder
  86. core="active"
  87. location="data/pop_rtfs/ACTIVE (160)"
  88. Import
  89. exit;;
  90. e) # index EXPANDING folder
  91. core="expanding"
  92. location="data/pop_rtfs/EXPANDING (169)"
  93. Import
  94. exit;;
  95. i) # index INVISIBLE folder
  96. core="invisible"
  97. location="data/pop_rtfs/IN.VISIBLE (204)"
  98. Import
  99. exit;;
  100. m) # index MULTI-SPECIES folder
  101. core="multispecies"
  102. location="data/pop_rtfs/MULTI-SPECIES (180)"
  103. Import
  104. exit;;
  105. p) # index PISSING & LEAKING folder
  106. core="pissing"
  107. location="data/pop_rtfs/PISSING & LEAKING (168)"
  108. Import
  109. exit;;
  110. x) # index SECRET folder
  111. core="secret"
  112. location="data/pop_rtfs/SECRET (92)"
  113. Import
  114. exit;;
  115. d) # index SELF-DEFENDING folder
  116. core="defending"
  117. location="data/pop_rtfs/SELF-DEFENDING (115)"
  118. Import
  119. exit;;
  120. s) # index SURVIVING folder
  121. core="surviving"
  122. location="data/pop_rtfs/SURVIVING (166)"
  123. Import
  124. exit;;
  125. w) # index WORKING folder
  126. core="working"
  127. location="data/pop_rtfs/WORKING (101)"
  128. Import
  129. exit;;
  130. \?) # Invalid option
  131. echo "Error: Invalid option"
  132. exit;;
  133. esac
  134. done