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 ...
随机推荐
- 【转】AWK 简明教程
本文转自:http://coolshell.cn/articles/9070.html 有一些网友看了前两天的<Linux下应该知道的技巧>希望我能教教他们用awk和sed,所以,出现了这 ...
- Android开发之---Activity生命周期
Android开发中,有四大组件:Activity.Service.Content Provider.Broadcast Receiver,可以说,activity的使用是最频繁的了,这里来梳理一下与 ...
- Linux常用命令学习4---(挂载命令mount umount、用户登陆查看和用户交互命令 w who last lastlog)
紧接着上一篇Linux的命令行的学习:Linux学习3---(文件的压缩和解压缩命令zip unzip tar.关机和重启命令shutdown reboot……) 1.挂载命令 简介 ...
- Java中分割字符串
java.lang.String 的 split() 方法, JDK 1.4 or later public String[] split(String regex,int limit) 示例代码 p ...
- 【转载】Linux常用命令列表
原文地址:http://www.cnblogs.com/Javame/p/3968343.html 1 目录与文件操作 1.1 ls(初级) 使用权限:所有人 功能 : 显示指定工作目录下之内容(列出 ...
- UWP webview 键盘bug,回退页面,键盘会弹一下。
最新项目发现一个关于Webview的键盘bug. 具体问题:当点击Webview 网页里面input之类的东东,输入键盘会弹出来,这个时候,按回退键,键盘会收起来,再按回退键,界面会退到前一个页面,但 ...
- shell example02
输入值 //相加 add(){ echo "add two agrs..." echo "enter first one: " read arg1 echo & ...
- <base>元素
HTML <base> 元素 <base> 标签描述了基本的链接地址/链接目标,该标签作为HTML文档中所有的链接标签的默认链接: <head><base h ...
- 【TYVJ1864】[Poetize I]守卫者的挑战 概率与期望
[TYVJ1864][Poetize I]守卫者的挑战 描述 打开了黑魔法师Vani的大门,队员们在迷宫般的路上漫无目的地搜寻着关押applepi的监狱的所在地.突然,眼前一道亮光闪过."我 ...
- codeforces泛做..
前面说点什么.. 为了完成日常积累,傻逼呵呵的我决定来一发codeforces 挑水题 泛做.. 嗯对,就是泛做.. 主要就是把codeforces Div.1的ABCD都尝试一下吧0.0.. 挖坑0 ...