solr6.5.1(2)定时增量更新

近期电商项目需要用到solr服务,之前对solr了解不多,最近主要做了安装solr,刚开始用docker安装,后续感觉docker维护起来比较费劲,原本直接丢进Tomcat就能启动了,何必搞那么麻烦。废话不多,记录下今天解决当前最新版本6.5.1的定时增量更新问题

1.依赖jar包

官方给的jar比较老了,新版本的实例化更新了方式,这个jar的源码也需要更新了,主要调整方式主要参考了博客:http://blog.csdn.net/yxue1118/article/details/51800145
我更改的jar包在此下载:
http://download.csdn.net/detail/a1556274485/9860262

2.配置文件

在solr_home下新建conf文件夹,将dataimport.properties放在该目录下
dataimport.properties内容如下:

# dataimport.properties example
#
# From this example, copy everything bellow "dataimport scheduler properties" to your
#   dataimport.properties file and then change params to fit your needs
#
# IMPORTANT:
# Regardless of whether you have single or multiple-core Solr,
#   use dataimport.properties located in your solr.home/conf (NOT solr.home/core/conf)
# For more info and context see here:
# http://wiki.apache.org/solr/DataImportHandler#dataimport.properties_example


#Tue Jul 21 12:10:50 CEST 2010
metadataObject.last_index_time=2010-09-20 11\:12\:47
last_index_time=2010-09-20 11\:12\:47


#################################################
#                                               #
#       dataimport scheduler properties         #
#                                               #
#################################################

#  to sync or not to sync
#  1 - active; anything else - inactive
syncEnabled=1

#  which cores to schedule
#  in a multi-core environment you can decide which cores you want syncronized
#  leave empty or comment it out if using single-core deployment
syncCores=solr-test

#  solr server name or IP address
#  [defaults to localhost if empty]
server=localhost

#  solr server port
#  [defaults to 80 if empty]
port=8080

#  application name/context
#  [defaults to current ServletContextListener's context (app) name]
webapp=solr

#  URL params [mandatory]
#  remainder of URL
##params=/select?qt=/dataimport&command=delta-import&clean=false&commit=true
params=/dataimport?command=delta-import&clean=false&commit=true&optimize=false&wt=json&indent=true&entity=data&verbose=false&debug=false

#  schedule interval
#  number of minutes between two runs
#  [defaults to 30 if empty]
interval=10

3.web.xml增加监听

将以下代码添加进web.xml:


    
      org.apache.solr.handler.dataimport.scheduler.ApplicationListener
    
  

4.重启solr项目,查看日志情况,若日志输出正常,则配置无误

你可能感兴趣的:(solr6.5.1(2)定时增量更新)