solr5.2 mysql 增量索引
前提:数据库里数据进行增删改操作时,相应的solr需要修改或者新建索引,之前从数据库中导入数据并创建索引的操作是全量创建,如果本身数据库数据量非常大,就需要增量创建索引
1./usr/local/src/solr-5.2.1/server/solr/doc/conf 中solrconfig.xml,添加下面的内容
这个是全量创建索引
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">data-config.xml</str>
</lst>
</requestHandler>
下面这个是增量
<requestHandler name="/deltaimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">delta-data-config.xml</str>
</lst>
</requestHandler>
2./usr/local/src/solr-5.2.1/server/solr/doc/conf中data-config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<dataConfig>
<dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/documents" user="root" password="12345"/>
<document>
<entity name="doc_import" pk="id" query="select id,file_name,file_type,file_path,file_content from document">
<field column="id" name="id" />
<field column="file_name" name="file_name" />
<field column="file_type" name="file_type" />
<field column="file_path" name="file_path" />
<field column="file_content" name="file_content" />
</entity>
<deltaImportQuery>
</deltaImportQuery>
</document>
</dataConfig>
3./usr/local/src/solr-5.2.1/server/solr/doc/conf中delta-data-config.xml
数据库中有一个create_time,默认是CURRENT_TIMESTAMP
<dataConfig>
<dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/documents" user="root" password="12345"/>
<document name="doc">
<entity dataSource="jdbcDataSource" name="doc_import_add"
query="select id,file_name,file_type,file_path,file_content from document"
deltaImportQuery="select id,file_name,file_type,file_path,file_content from document where id= ${dih.delta.id}"
deltaQuery="select id,file_name,file_type,file_path,file_content from document where creat_time > '${dih.last_index_time}'">
<field column="id" name="id" />
<field column="file_name" name="file_name" />
<field column="file_type" name="file_type" />
<field column="file_path" name="file_path" />
<field column="file_content" name="file_content" />
</entity>
</document>
</dataConfig>
4.重启solr
solr5.2 mysql 增量索引的更多相关文章
- [Solr] (源) Solr与MongoDB集成,实时增量索引
一. 概述 大量的数据存储在MongoDB上,需要快速搜索出目标内容,于是搭建Solr服务. 另外一点,用Solr索引数据后,可以把数据用在不同的项目当中,直接向Solr服务发送请求,返回xml.js ...
- coreseek增量索引
1.在多数情况下,因为Coreseek索引速度高达10MB/s,所以只需要创建一个索引源即可满足需求,但是在数据量随时激增的大型应用中(如SNS.评论系统等),单一的索引源将会给indexer造成极大 ...
- sphinx通过增量索引实现近实时更新
一.sphinx增量索引实现近实时更新设置 数据库中的已有数据很大,又不断有新数据加入到数据库中,也希望能够检索到.全部重新建立索引很消耗资源,因为我们需要更新的数据相比较而言很少. 例如.原来的数据 ...
- sphinx 增量索引 实现近实时更新
一.sphinx增量索引的设置 数据库中的已有数据很大,又不断有新数据加入到数据库中,也希望能够检索到.全部重新建立索引很消耗资源,因为我们需要更新的数据相比较而言很少.例如.原来的数据有几百万条 ...
- sphinx增量索引
首先建立一个计数表,保存数据表的最新记录ID CREATE TABLE `sph_counter` ( `id` int(11) unsigned NOT NULL, `max_id` int(1 ...
- Sphinx 增量索引更新
是基于PHP API调用,而不是基于sphinxSE.现在看来sphinxSE比API调用更简单的多,因为之前没有想过sphinxSE,现在先把API的弄明白.涉及到的:sphinx 数据源的设置,简 ...
- sphinx续5-主索引增量索引和实时索引
原文件地址:http://blog.itpub.net/29806344/viewspace-1400942/ 在数据库数据非常庞大的时候,而且实时有新的数据插入,如果我们不更新索引,新的数据就sea ...
- sphinx 增量索引 及时更新、sphinx indexer索引合成时去旧和过滤办法(转)
一.sphinx增量索引的设置 数据库中的已有数据很大,又不断有新数据加入到数据库中,也希望能够检索到.全部重新建立索引很消耗资源,因为我们需要更新的数据相比较而言很少.例如.原来的数据有几百万 ...
- sphinx (coreseek)——3、区段查询 与 增量索引实例
首先本文测试数据100多万的域名的wwwtitle 信息 检索数据: 首先建立临时表格: CREATE TABLE `sph_counter` ( `index_id` ) NOT NULL, `m ...
随机推荐
- HDU 4113 Construct the Great Wall(插头dp)
好久没做插头dp的样子,一开始以为这题是插头,状压,插头,状压,插头,状压,插头,状压,无限对又错. 昨天看到的这题. 百度之后发现没有人发题解,hust也没,hdu也没discuss...在acm- ...
- 图片切换小demo
<body> <div class="body"><img src="bopin/images/bigImg1.jpg" widt ...
- thinkphp 3.23语言包加载
模块home: 1.config 里添加 配置 //'配置项'=>'配置值' 'LANG_SWITCH_ON' => true, // 开启语言包功能 'LANG ...
- 【Java EE 学习 46】【Hibernate学习第三天】【多对多关系映射】
一.多对多关系概述 以学生和课程之间的关系为例. 1.在多对多关系中涉及到的表有三张,两张实体表,一张专门用于维护关系的表. 2.多对多关系中两个实体类中应当分别添加对方的Set集合的属性,并提供se ...
- 3D场景定位的一些资源
利用多张影像对小物体进行拍摄,进而进行三维重建,是计算机视觉中的重要问题之一. 目前对此研究最全面的网站是:http://vision.middlebury.edu/mview/eval/ 目前最优秀 ...
- Install MySQL on CentOS 7
原文:https://devops.profitbricks.com/tutorials/install-mysql-on-centos-7/ 1.下载mysql 在mysql官网选择适合的mysql ...
- shell example01
条件判断 if [[ -e ${1} ]]; then echo "$(tput setaf 2) found ${1} $(tput sgr0)" cat ${1} else e ...
- POJ 2559 Largest Rectangle in a Histogram ——笛卡尔树
[题目分析] 本来是单调栈的题目,用笛卡尔树可以快速的水过去. 把每一个矩阵看成一个二元组(出现的顺序,高度). 然后建造笛卡尔树. 神奇的发现,每一个节点的高度*该子树的大小,就是这一块最大的子矩阵 ...
- Subsonic的使用之基本语法、操作(2)
查询 SubSonic2.1版本 – 例出3种查询. Product product = new Select().From<Product>() .Where(Product.Produ ...
- Page-encoding specified in XML prolog (UTF-8) is different from that specified in page directive (utf-8)
org.apache.jasper.JasperException:xxx.jsp(1,1) Page-encoding specified in XML prolog (UTF-8) is diff ...