Solr5.0.0定时更新索引
由于通过配置的方式定时更新不生效,故通过代码执行定时任务更新
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定时更新索引的更多相关文章
- sorl 6.6.0 定时更新索引
solr 定时更新索引 – solr 6.6.0 – dataimport.scheduler 这里先重点说下,定时更新引用的org.apache.solr.handler.dataimport.sc ...
- solr全文检索原理及solr5.5.0 Windows部署
文章原理链接:http://blog.csdn.net/xiaoyu411502/article/details/44803859 自己稍微总结:全文检索主要有两个过程:创建索引,搜索索引 创建索引: ...
- Solr5.4.0部署到Tomcat
所用工具 下载 solr 5.4.0 版本:http://www.apache.org/dyn/closer.lua/lucene/solr/5.4.0 下载 Tomcat(6以上版本),另外可以根据 ...
- Sitecore8.2 Solr5.1.0配置步骤
1.首先下载Solr安装包,官方提供了几种下载,我选的的solr的5.1.0版本zip包,下载链接:http://mirror.bit.edu.cn/apache/lucene/solr. 2.下载后 ...
- spring注解 @Scheduled(cron = "0 0 1 * * *")实现定时的执行任务
@Scheduled(cron = "0 0 1 * * *") 在使用该注解以前请做好以下准备工作,配置好相应的xm文件. 配置定时注解的步骤:http://blog.csdn. ...
- 使用SolrNet访问Solr-5.5.0
由于今年年初刚发布的Solr-5.5.0,网上所能找到的资料少之又少,所以只能靠自己一点点摸索. 从某Hub上下载了SolrNet源码,按照教程提交文档或者查询均失败,无奈只得跟断点一点点差怎么回事. ...
- solr5.5.0在CenOS上的安装与配置
solr5.5.0在CenOS上的安装与配置 1. Solr简介 Solr是一个基于Lucene的Java搜索引擎服务器.Solr 提供了层面搜索.命中醒目显示并且支持多种输出格式(包括 XML/XS ...
- solr 搭建 (基于solr-5.0.0)
1)去官网下载solr 2)去官网下载Tomcat 3)在D盘建一个文件夹(我在此建立了一个文件夹(命名为:sorl_lf)) 4)解压Tomcat(如果已经安装了Tomcat,请配置支持多个Tomc ...
- linux下solr5.0.0环境搭建
1解压 linux下解压命令 tar -zxvf solr-5.0.0.tgz 2启动 linux 系统 直接切换solr-5.0.0\bin 文件夹 执行 solr star -p 8983 (如果 ...
随机推荐
- Windows、Linux、Android常用软件分享
Windows.Linux.Android常用软件分享 前言 本来没准备写这篇博客,一是没时间,还有其他很多优先级更高的事情要做.二是写这种博客对我自己来说没什么的帮助,以前我就想好了不写教程类,使用 ...
- JSP | 基础 | JSP行为 | incline && forward
语法 描述 jsp:include 用于在当前页面中包含静态或动态资源 jsp:forward 从一个JSP文件向另一个文件传递一个包含用户请求的request对象 index.jsp <%@ ...
- Educational Codeforces Round 46 (Rated for Div. 2) A. Codehorses T-shirts
Bryce1010模板 http://codeforces.com/problemset/problem/1000/A 题意: 问你将一种类型的衣服转换成另一种的最小次数. #include<b ...
- 题解报告:poj 1738 An old Stone Game(区间dp)
Description There is an old stone game.At the beginning of the game the player picks n(1<=n<=5 ...
- Datapatch AND What to do if the status of a datapatch action was not SUCCESS due to finding non-ignorable errors
1. Enterprise Manager: Starting version 12.1 Enterprise Manager now calls datapatch to complete post ...
- go获取当前执行的位置程序
func getCurrentPath() string { _, filename, _, ok := runtime.Caller(1) var cwdPath string if ok { cw ...
- iOS 随笔 允许所有不安全网络访问项目
允许任意请求访问app App Transport Security Settings -> Allow Arbitrary Loads YES
- K-means算法Java实现
public class KMeansCluster { private int k;//簇的个数 private int num = 100000;//迭代次数 ...
- MVC之在实例中的应用
MVC模式在Java Web应用程序中的实例分析 1. 结合六个基本质量属性 1)可用性 2)可修改性 3)性能 4)安全性 5)可测试性 6)易用性 2. 分析具体功能模块的MVC设计实现(例如登录 ...
- core mvc 分页
看了下XPAGE感觉还是用的不太爽,自己写了个,样式是bootstrap的,需要的小伙伴拿走吧. public static IHtmlContent Pager(this IHtmlHelper h ...