本篇内容主要讲解“solr dataimporter定时任务怎么实现”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“solr dataimporter定时任务怎么实现”吧!
下载的包放到tomcat 的solr 应用下。
包中的dataimport.properties 文件放到server/solr/conf目录下。(conf 目录需要自己新建)
修改 dataimport.properties
#################################################
# #
# 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=core #改成自己的
# 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=/core/dataimport?command=delta-import&clean=false&commit=true
# schedule interval
# number of minutes between two runs
# [defaults to 30 if empty]
interval=10
需要在数据库表加一个时间戳字段用来增量更新的时候进宪判断。其他字段亦可。
导入数据的配置文件中entity 的deltaQuery="。。。 where last_index_time > ${dataimporter.last_index_time}"
在solr 应用的 web.xml中添加listener
<listener>
<listener-class>org.apache.solr.handler.dataimport.scheduler.ApplicationListener</listener-class>
</listener>
到此,相信大家对“solr dataimporter定时任务怎么实现”有了更深的了解,不妨来实际操作一番吧!这里是天达云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!