Pastebin is 300% more awesome when you are logged in. Sign Up, it's FREE!
Guest

DSE SOLR setup

By: Strafer on Nov 22nd, 2013  |  syntax: Bash  |  size: 4.42 KB  |  hits: 43  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. alan@karma:cust cat create_cust.sh
  2. #!/bin/sh
  3. # solrconfig.xml schema.xml
  4. # stopword_num.txt stopword_org.txt stopword_phone.txt
  5. # synonym_addr.txt synonym_ind.txt synonym_org.txt
  6.  
  7. KSCF=search.cust
  8.  
  9. for arg
  10. do
  11.   case "$arg" in
  12.  
  13.   config)
  14.     echo Posting solrconfig.xml
  15.     $TEST curl http://localhost:8983/solr/resource/$KSCF/solrconfig.xml --data-binary @solrconfig.xml -H 'Content-type:text/xml; charset=utf-8'
  16.     ;;
  17.  
  18.   schema)
  19.     echo Posting the schema file:
  20.     $TEST curl http://localhost:8983/solr/resource/$KSCF/schema.xml --data-binary @schema.xml -H 'Content-type:text/xml; charset=utf-8'
  21.     ;;
  22.  
  23.   stop*)
  24.     echo Posting the stopword files:
  25.     for stop in num org phone
  26.     do
  27.       $TEST curl http://localhost:8983/solr/resource/$KSCF/stopword_$stop.txt --data-binary \
  28.       stopword_$stop.txt -H 'Content-type:text/xml; charset=utf-8'
  29.     done
  30.     ;;
  31.  
  32.   syn*)
  33.     echo Posting the synonym files:
  34.     for syn in addr ind org
  35.     do
  36.       $TEST curl http://localhost:8983/solr/resource/$KSCF/synonym_$syn.txt --data-binary \
  37.       synonym_$syn.txt -H 'Content-type:text/xml; charset=utf-8'
  38.     done
  39.     ;;
  40.  
  41.   create|make|core|index)
  42.      # specific to Datastaxe Enterprise Search:
  43.      # http://www.datastax.com/docs/datastax_enterprise3.1/solutions/dse_search_upload
  44.      CREATE_URL="http://localhost:8983/solr/admin/cores?action=CREATE&name=$KSCF"
  45.      echo "Creating core index $KSCF"
  46.      $TEST curl -s -X POST $CREATE_URL
  47.      echo "Created core index $KSCF"
  48.     ;;
  49.  
  50.   reindex|rebuild)
  51.      # http://www.datastax.com/docs/datastax_enterprise3.1/solutions/dse_search_reload_core#partial-reindex
  52.      UPDATE_URL="http://localhost:8983/solr/admin/cores?action=RELOAD&name=$KSCF&reindex=true&deleteAll=false"
  53.      echo "Recreating core index $KSCF"
  54.      $TEST curl -s -X POST $UPDATE_URL
  55.      echo "Recreated core index $KSCF"
  56.      ;;
  57.   startover)
  58.      # http://www.datastax.com/docs/datastax_enterprise3.1/solutions/dse_search_reload_core#partial-reindex
  59.      UPDATE_URL="http://localhost:8983/solr/admin/cores?action=RELOAD&name=$KSCF&reindex=true&deleteAll=true"
  60.      echo "Recreating core index $KSCF"
  61.      $TEST curl -s -X POST $UPDATE_URL
  62.      echo "Recreated core index $KSCF"
  63.      ;;
  64.   esac
  65. done
  66.  
  67. alan@karma:cust TEST=echo create*sh config schema syn create |grep curl
  68. curl http://localhost:8983/solr/resource/search.cust/solrconfig.xml --data-binary @solrconfig.xml -H Content-type:text/xml; charset=utf-8
  69. curl http://localhost:8983/solr/resource/search.cust/schema.xml --data-binary @schema.xml -H Content-type:text/xml; charset=utf-8
  70. curl http://localhost:8983/solr/resource/search.cust/synonym_addr.txt --data-binary synonym_addr.txt -H Content-type:text/xml; charset=utf-8
  71. curl http://localhost:8983/solr/resource/search.cust/synonym_ind.txt --data-binary synonym_ind.txt -H Content-type:text/xml; charset=utf-8
  72. curl http://localhost:8983/solr/resource/search.cust/synonym_org.txt --data-binary synonym_org.txt -H Content-type:text/xml; charset=utf-8
  73. curl -s -X POST http://localhost:8983/solr/admin/cores?action=CREATE&name=search.cust
  74. alan@karma:cust
  75. alan@karma:cust cat post.sh
  76. #!/bin/sh
  77. # Licensed to the Apache Software Foundation (ASF) under one or more
  78. # contributor license agreements.  See the NOTICE file distributed with
  79. # this work for additional information regarding copyright ownership.
  80. # The ASF licenses this file to You under the Apache License, Version 2.0
  81. # (the "License"); you may not use this file except in compliance with
  82. # the License.  You may obtain a copy of the License at
  83. #
  84. #     http://www.apache.org/licenses/LICENSE-2.0
  85. #
  86. # Unless required by applicable law or agreed to in writing, software
  87. # distributed under the License is distributed on an "AS IS" BASIS,
  88. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  89. # See the License for the specific language governing permissions and
  90. # limitations under the License.
  91.  
  92. REPLACE=${REPLACE:-false}
  93. RPL="?replacefields=$REPLACE"
  94. KSCF=search.cust
  95. URL=http://localhost:8983/solr/$KSCF/update$RPL
  96.  
  97. for f
  98. do
  99.   echo Posting file $f to $URL
  100.   $TEST curl $URL --data-binary @$f -H 'Content-type:application/xml'
  101.   echo
  102. done
  103.  
  104.  
  105. alan@karma:cust TEST=echo post.sh  joe6.xml
  106. Posting file joe6.xml to http://localhost:8983/solr/search.cust/update?replacefields=false
  107. curl http://localhost:8983/solr/search.cust/update?replacefields=false --data-binary @joe6.xml -H Content-type:application/xml