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

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. UIImageView 使图片圆形的方法

    UIImageView 圆形的两种方法 1.cornerRadius (tableView,collectionView尽量避免使用,影响性能) //想要圆角 cornerRadius必须是 imag ...

  2. hdu1325 Is It A Tree? 基础并查集

    #include <stdio.h> #include <string.h> ], g[]; int find(int x) //并查集的查找,找到共同的父亲 { if (f[ ...

  3. Python转载

    让Python的经验更多一点 Python while 1 和 while True 速度比较 Python %s和%r的区别

  4. 快速分页:jsp标签pager-taglib

    一:简介 Pager-taglib,支持多种风格的分页显示.实际上它是一个Jsp标签库,为在JSP上显示分页信息而设计的一套标签,通过这些标签的不同的组 合,会形成多种不一样的分页页面,风格各异.它既 ...

  5. 18.3.2从Class上获取信息(方法)

    package d18_3_1; import java.lang.reflect.Method; import java.util.Arrays; /** * 获取Class对应类所包含的方法的四个 ...

  6. 记录两个python itchat的用法博客网址

    http://www.tuicool.com/articles/VJZRRfn https://itchat.readthedocs.io/zh/latest/

  7. P2955 [USACO09OCT]奇数偶数Even? Odd?

    题目描述 Bessie's cruel second grade teacher has assigned a list of N (1 <= N <= 100) positive int ...

  8. node入门(三)——gulp运用实例

    在上一篇<node入门(二)——gulpfile.js初探>中,我们知道了(看懂入门二及其参考资料)怎么运用gulp来更高效的开发,现在来示范一下. 在package.json里面配置好d ...

  9. mysql 查询数据库参数命令

    1.select @@tx_isolation;    查询数据库设置的事务隔离级别 2.desc table_name;  显示表设计 3.show create table table_name; ...

  10. SQL 导出csv

    https://jingyan.baidu.com/album/4b07be3c466b5d48b280f37f.html?picindex=9