recursive9
recursive9

Reputation: 340

Force Solr to read from an updated index

I have a lucene index that i build and update using raw lucene indexers. I was wondering if there is a way to force solr to re-read the index without restarting the solr instance. Ive tried the update?commit=true but it doesnt seem to matter. The only way i can be sure solr -re-reads the index is by a total restart, which of course is not ideal in a production environment.

Upvotes: 1

Views: 758

Answers (2)

Xoroz
Xoroz

Reputation: 437

Not sure if there is another better way to do it. But I wrote this script to perform full or delta imports.

#!/bin/bash
# script to index Solr
# by Felipe Ferreira Sept 2013

TYPE=$1
DATE=`date +%d_%m_%y`
DATEFULL=`date +%H:%M:%S_%d_%m_%y`
LOG="/var/log/solr/solr_import_${TYPE}_${DATE}.log"
LOGTMP="/var/log/solr/solr_status_${DATE}.log"

URL="http://<SERVER>:8080/solr/dataimport?command=status"



pt() {
echo -e $1
echo -e $1 >> $LOG
} 

if [ $TYPE == "full" ]; then
   pt "$DATEFULL - Starting full import"
   URL="http://<SERVER>:8080/solr/dataimport?command=full-import" 
#   CMD="curl --location --no-buffer --fail --silent --output ${LOG} '${URL}'"
   CMD="curl --location --silent --no-buffer '${URL}' >> $LOG"
   pt "Executing $CMD"
   CMD_E=`eval $CMD`
   pt $CMD_E
elif  [ $TYPE == "delta" ]; then
   pt "$DATEFULL - Starting delta import"
   URL="http://<SERVER>:8080/solr/dataimport?command=delta-import" 
   #CMD="curl --location --no-buffer --fail --silent --output ${LOG} '${URL}'"
   CMD="curl --location --silent --no-buffer '${URL}' >> $LOG"
   pt "Executing $CMD"
   CMD_E=`eval $CMD`
   pt $CMD_E
else
   pt  "ERROR - $TYPE not found, only delta or full,\n Usage: $0 delta/full"
fi

sleep 3

#check status after command
   pt "$DATEFULL - Checking $TYPE status" 
   URL="http://infofish2:9080/solrcadin/cadin/dataimport?command=status"
   CMD="curl --location --silent --no-buffer '${URL}' > $LOGTMP"
   pt "Executing $CMD"
   CMD_E=`eval $CMD`
   pt $CMD_E 
   CHECK=0
   CHECK=`grep -c failed $LOGTMP`
   if [ $CHECK -eq 0 ]; then
      pt "OK - Command $TYPE executed with success!"
      exit 0
   else

      pt "CRITICAL - Command $TYPE failed, solr did not index!"
      pt "grep -c failed $LOGTMP"
      pt "CHECK $CHECK"
      exit 0
   fi

Upvotes: 0

Pascal Dimassimo
Pascal Dimassimo

Reputation: 6928

If you are using a multi-core setup, you can just reload that single core. AFAIK, while the core is being reloaded, the requests to that core are queued.

Upvotes: 1

Related Questions