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 ...
随机推荐
- Find All Numbers Disappeared in an Array
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and ot ...
- jstl fortokens 分割字符串
forTokens标签: forTokens标签用来截取字符串: 属性: * var :定义变量 * items :切分字符串 * begin :从哪开始 * end :到哪结束 * step :步长 ...
- HtmlAgilityPack 学习和笔记
介绍: http://www.cnblogs.com/bomo/archive/2013/01/28/2879361.html 实战 c#获取外网ip 网址:http://ip138.com/ 如图: ...
- selenium+testng+ant+jenkins 手记
会不会搭建测试平台是一般测试工程师和高级测试工程师分水岭 ----tobecrazy 我们项目有现成的测试平台,使用的是selenium grid+testng+ant+jenkins+VM 但是我平 ...
- 【转】android中ListView的定位:使用setSelectionFromTop实现ListView的position的保持
如果一个ListView太长,有时我们希望ListView在从其他界面返回的时候能够恢复上次查看的位置,这就涉及到ListView的定位问题: 解决的办法如下: 1 2 3 4 5 6 7 // 保存 ...
- iOS 归档archive使用方法
归档是一种很常用的文件储存方法,几乎任何类型的对象都能够被归档储存,文件将被保存成自定 义类型的文件,相对于NSUserDefault具有更好的保密性. 1.使用archiveRootObject ...
- 在VFP6中模拟CursorAdapter的功能
这个是我在2002年做的一个VFP程序中实现的方法, 现在看来功能和VFP8,9中的CursorAdapter非常相似, 因为属性设置有许多相同的地方,我甚至怀疑CA就是就是在这样的基础上再包装出来的 ...
- win10预览版9926升级10049操作步骤
文章转自:豆豆系统收藏备用 win10预览版系统安装的用户非常多,现在最新版本已经到了10049,但是之前很多装了9926版本或者10041版本的同学在通过系统自动更新的时候,且发现,微软官方提供的速 ...
- CAEmitterLayer实现雪花效果
CAEmitterLayer 简介 在iOS5.0中,Apple引入了CAEmitterLayer层,CAEmitterLayer是一个高性能的粒子效果引擎,被用来创建实时粒子动画,如:烟雾,火,雨等 ...
- SQL入门语句之LIKE、GLOB和LIMIT
一.SQL入门语句之LIKE LIKE用来匹配通配符指定模式的文本值.如果搜索表达式与模式表达式匹配,LIKE 运算符将返回真(true),也就是 1.这里有两个通配符与 LIKE 运算符一起使用,百 ...