由于通过配置的方式定时更新不生效,故通过代码执行定时任务更新

package com.thinkgem.jeesite.modules.meeting.task;

import java.io.IOException;

import org.apache.http.HttpStatus;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; /**
* @ClassName: SolrTask
* @Description:
* @author wd
* @date 2018年3月23日 上午11:13:22
*
*/
@Service
@Lazy(false)
public class SolrTask { @Value("#{APP_PROP['solr.Core.full']}")
private String coreUrlfull; @Value("#{APP_PROP['solr.Core.delta']}")
private String coreUrldelta; private static final Logger LOGGER = LoggerFactory.getLogger(SolrTask.class); /**
*
* 适用于修改 新增 (删除未做)
* 每日零点
* @throws IOException
*/
@Scheduled(cron = "0 0 0 * * ?")
public void SolrTaskDelta() throws IOException {
CloseableHttpClient httpCilent = HttpClients.createDefault();
HttpGet httpGet = new HttpGet(coreUrldelta);
try {
CloseableHttpResponse response = httpCilent.execute(httpGet);
if (response != null && response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
LOGGER.info("solr增量索引任务执行成功" );
}
} catch (IOException e) {
LOGGER.info("solr增量索引任务执行失败");
e.printStackTrace();
}finally {
httpCilent.close();
}
} /**
* 每周一零点
* 全量索引删除后重建
* @throws IOException
*
*/
@Scheduled(cron = "0 0 0 ? * MON ")
public void SolrTaskFull() throws IOException {
CloseableHttpClient httpCilent = HttpClients.createDefault();
HttpGet httpGet = new HttpGet(coreUrlfull);
try {
CloseableHttpResponse response = httpCilent.execute(httpGet);
if (response != null && response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
LOGGER.info("solr重建全量索引成功" );
}
} catch (IOException e) {
LOGGER.info("solr重建全量索引失败");
e.printStackTrace();
}finally {
httpCilent.close();
}
}
}
#期刊索引更新测试服务器
solr.Core.delta=http://10.1.101.134:8983/solr/PaperReview/dataimport?command=delta-import&clean=false&commit=true
solr.Core.full=http://10.1.101.134:8983/solr/PaperReview/dataimport?command=full-import&clean=true&commit=true

Solr5.0.0定时更新索引的更多相关文章

  1. sorl 6.6.0 定时更新索引

    solr 定时更新索引 – solr 6.6.0 – dataimport.scheduler 这里先重点说下,定时更新引用的org.apache.solr.handler.dataimport.sc ...

  2. solr全文检索原理及solr5.5.0 Windows部署

    文章原理链接:http://blog.csdn.net/xiaoyu411502/article/details/44803859 自己稍微总结:全文检索主要有两个过程:创建索引,搜索索引 创建索引: ...

  3. Solr5.4.0部署到Tomcat

    所用工具 下载 solr 5.4.0 版本:http://www.apache.org/dyn/closer.lua/lucene/solr/5.4.0 下载 Tomcat(6以上版本),另外可以根据 ...

  4. Sitecore8.2 Solr5.1.0配置步骤

    1.首先下载Solr安装包,官方提供了几种下载,我选的的solr的5.1.0版本zip包,下载链接:http://mirror.bit.edu.cn/apache/lucene/solr. 2.下载后 ...

  5. spring注解 @Scheduled(cron = "0 0 1 * * *")实现定时的执行任务

    @Scheduled(cron = "0 0 1 * * *") 在使用该注解以前请做好以下准备工作,配置好相应的xm文件. 配置定时注解的步骤:http://blog.csdn. ...

  6. 使用SolrNet访问Solr-5.5.0

    由于今年年初刚发布的Solr-5.5.0,网上所能找到的资料少之又少,所以只能靠自己一点点摸索. 从某Hub上下载了SolrNet源码,按照教程提交文档或者查询均失败,无奈只得跟断点一点点差怎么回事. ...

  7. solr5.5.0在CenOS上的安装与配置

    solr5.5.0在CenOS上的安装与配置 1. Solr简介 Solr是一个基于Lucene的Java搜索引擎服务器.Solr 提供了层面搜索.命中醒目显示并且支持多种输出格式(包括 XML/XS ...

  8. solr 搭建 (基于solr-5.0.0)

    1)去官网下载solr 2)去官网下载Tomcat 3)在D盘建一个文件夹(我在此建立了一个文件夹(命名为:sorl_lf)) 4)解压Tomcat(如果已经安装了Tomcat,请配置支持多个Tomc ...

  9. linux下solr5.0.0环境搭建

    1解压 linux下解压命令 tar -zxvf solr-5.0.0.tgz 2启动 linux 系统 直接切换solr-5.0.0\bin 文件夹 执行 solr star -p 8983 (如果 ...

随机推荐

  1. vbox虚拟机配置Redhat6.4本地yum源

    作为一个新手,配置这个yum源配了4天,遇到了各种问题,也按照网络上面一些方法在163上面下载CentOS6的yum源来替换Redhat本地的yum源,但是配置过程中,出现很多错误,发现直接在本地配置 ...

  2. wpf 中AxShockwaveFlash重写以及屏蔽鼠标右键

    在wpf中需要用到flash播放swf或者图片,需要使用 AxShockwaveFlashObjects.dll和ShockwaveFlashObjects.dll 在项目中使用的时候遇到 问题1.使 ...

  3. 跟我一起玩Win32开发(11):使用控件——先来耍一下按钮

    用户通过控件与应用程序交互,在吹牛之前,先介绍一个工具,这是官方的工具,使用它,你可以预览常用控件的外观.样式,以及对控进行操作时接收和发送哪些消息.下载地址如下: http://www.micros ...

  4. pika消息中间件模块

    参考: http://www.rabbitmq.com/tutorials/tutorial-one-python.html http://www.rabbitmq.com/tutorials/tut ...

  5. JMeter配置JDBC测试SQL Server/MySQL

    一.配置SQL Server 1.下载sql驱动,将sqljdbc4.jar放到JMeter安装目录/lib下. 2.启动JMeter,右键添加->配置文件->JDBC Connectio ...

  6. python之文件的读写

    读  r   读写模式   r+     如果打开文件时没有指定模式,默认只读,如果使用r或r+,文件不存在时会报错 写  w  写读模式  w+    w模式会清空原有的文件内容 追加 a  追加读 ...

  7. Educational Codeforces Round 46 (Rated for Div. 2) E. We Need More Bosses

    Bryce1010模板 http://codeforces.com/contest/1000/problem/E 题意: 给一个无向图,求图的最长直径. 思路:对无向图缩点以后,求图的最长直径 #in ...

  8. Math Show CodeForces - 846B

    题目 题意: 有n个任务,每个任务有k个子任务,有m的时间来完成任务.每个任务的第i个子任务需要时间都是ti.完成一个子任务获得一分,完成一个大任务的所有子任务额外得一分.问如何在时间不超过m的情况下 ...

  9. web 另类方法实现“另存为”功能

    HTML5 的 FileReader 带给我们很强大的文件只读访问能力,可是在 HTML5 新增的 JS 中却没有发现有方便的另存到本地文件的相关 API,以往的办法要么调用浏览器的 save as ...

  10. UESTC - 878 温泉旅店 二维费用背包问题

    http://acm.uestc.edu.cn/#/problem/show/878 设dp[i][j][k]表示在前i个数中,第一个得到的异或值是j,第二个人得到的异或值是k的方案数有多少种. 因为 ...