我有一个lucene索引,我使用原始lucene索引器构建和更新。我想知道是否有办法强制solr重新读取索引而不重新启动solr实例。我尝试过更新?commit = true但似乎并不重要。我可以确定solr -re-read索引的唯一方法是完全重启,这当然在生产环境中并不理想。
答案 0 :(得分:1)
如果您使用的是多核设置,则可以只reload该单核。 AFAIK,当核心被重新加载时,对该核心的请求排队。
答案 1 :(得分:0)
不确定是否还有其他更好的方法。 但是我编写了这个脚本来执行完整或delta导入。
#!/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