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
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.

130 lines
4.4KB

  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 [-m|h|a|b]"
  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 "s Index SURVIVING folder."
  38. echo
  39. }
  40. Import()
  41. {
  42. docker exec -it solr bin/solr delete -c $core
  43. docker exec -it solr solr create_core -c $core -d custom
  44. #docker exec -ti --user=solr solr bash -c "cp -r /opt/solr/example/files/conf/* /var/solr/data/$core/conf/"
  45. docker restart solr
  46. sleep 30
  47. docker run --rm -v "$directory/$location:/$core" --network=host solr:latest post -c $core /$core
  48. }
  49. ############################################################
  50. ############################################################
  51. # Main program #
  52. ############################################################
  53. ############################################################
  54. # Set variables
  55. directory="/Users/ad7588/projects/patent_site"
  56. # Get the options
  57. while getopts ":hlimzaespxdw" option; do
  58. case $option in
  59. l) # display License
  60. License
  61. exit;;
  62. h) # display Help
  63. Help
  64. exit;;
  65. z) # index all
  66. core="all"
  67. location="data/pop_rtfs"
  68. Import
  69. exit;;
  70. a) # index ACTIVE folder
  71. core="active"
  72. location="data/pop_rtfs/ACTIVE (160)"
  73. Import
  74. exit;;
  75. e) # index EXPANDING folder
  76. core="expanding"
  77. location="data/pop_rtfs/EXPANDING (169)"
  78. Import
  79. exit;;
  80. i) # index INVISIBLE folder
  81. core="invisible"
  82. location="data/pop_rtfs/IN.VISIBLE (204)"
  83. Import
  84. exit;;
  85. m) # index MULTI-SPECIES folder
  86. core="multispecies"
  87. location="data/pop_rtfs/MULTI-SPECIES (180)"
  88. Import
  89. exit;;
  90. p) # index PISSING & LEAKING folder
  91. core="pissing"
  92. location="data/pop_rtfs/PISSING & LEAKING (168)"
  93. Import
  94. exit;;
  95. x) # index SECRET folder
  96. core="secret"
  97. location="data/pop_rtfs/SECRET (92)"
  98. Import
  99. exit;;
  100. d) # index SELF-DEFENDING folder
  101. core="defending"
  102. location="data/pop_rtfs/SELF-DEFENDING (115)"
  103. Import
  104. exit;;
  105. s) # index SURVIVING folder
  106. core="surviving"
  107. location="data/pop_rtfs/SURVIVING (166)"
  108. Import
  109. exit;;
  110. w) # index WORKING folder
  111. core="working"
  112. location="data/pop_rtfs/WORKING (101)"
  113. Import
  114. exit;;
  115. \?) # Invalid option
  116. echo "Error: Invalid option"
  117. exit;;
  118. esac
  119. done