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:

<listener>
    <listener-class>
      org.apache.solr.handler.dataimport.scheduler.ApplicationListener
    </listener-class>
  </listener>

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 47,168评论 6 342
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 136,179评论 19 139
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 176,552评论 25 709
  • 每个人都希望通过自己的努力,过上自己想要的生活。然而我们却总能听到抱怨,这不是我想要的生活,只因为你还不够努力。 ...
    三个太阳的雨林阅读 1,490评论 0 0
  • 即使在十八线城市,一个 规模强大的企业也可能会在一年之间宣布破产。与其到那时受父母埋怨,嫌没听从他们要你选择教师、...
    叶塞尼娅阅读 1,756评论 0 0

友情链接更多精彩内容