solr5.0.0的使用(二)
2016-07-27 10:23
253 查看
Solr提供了丰富的数据导入接口,可以导入数据库表、xml、json、csv各种格式的数据信息。
大多数的应用程序将数据存储在关系数据库、xml文件中。对这样的数据进行搜索是很常见的应用。所谓的DataImportHandler提供一种可配置的方式向solr导入数据,可以一次全部导入,也可以增量导入。他可以实现能够读取关系数据库中的数据。通过可配置的方式,能够将数据库中多列、多表的数据生成solr文档能够通过solr文档更新solr提供通过配置文件就能够导入所有数据的能力能够发现并处理 由insert、update带来的变化(我们假定在表中有一个叫做“last-modified的列”)能够配置"完全导入"和"增量导入"的时间让读取xml文件,并建立索引成为可配置。能够将
其他的数据源(例如:ftp,scp,etc)或者其他格式的文档(Json,csv)以插件的形式集成到项目中。
导入mysql数据库
配置workspace/temp_info/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>
配置workspace/temp_info/conf/schema.xml添加
<field name="temp_id" type="string" indexed="true" stored="true" multiValued="false" />
<field name="temp_name" type="string" indexed="true" stored="true" />
<field name="temp_phone" type="string" indexed="true" stored="true" />
注释掉
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
修改
<uniqueKey>id</uniqueKey>
为
<uniqueKey>temp_id</uniqueKey>
增加文件workspace/temp_info/conf/data-config.xml文件内容为
<?xml version="1.0" encoding="utf-8"?>
<dataConfig>
<dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://ip:3306/test?useUnicode=true&characterEncoding=utf-8" temp="name" password="password"/>
<document >
<entity name="parteam_test_temp" pk="temp_id" query="select a.temp_id as temp_id,a.nick_name as temp_name from temp_info a">
<field column="temp_id" name="temp_id" />
<field column="temp_name" name="temp_name" />
</entity>
</document>
</dataConfig>
大多数的应用程序将数据存储在关系数据库、xml文件中。对这样的数据进行搜索是很常见的应用。所谓的DataImportHandler提供一种可配置的方式向solr导入数据,可以一次全部导入,也可以增量导入。他可以实现能够读取关系数据库中的数据。通过可配置的方式,能够将数据库中多列、多表的数据生成solr文档能够通过solr文档更新solr提供通过配置文件就能够导入所有数据的能力能够发现并处理 由insert、update带来的变化(我们假定在表中有一个叫做“last-modified的列”)能够配置"完全导入"和"增量导入"的时间让读取xml文件,并建立索引成为可配置。能够将
其他的数据源(例如:ftp,scp,etc)或者其他格式的文档(Json,csv)以插件的形式集成到项目中。
导入mysql数据库
配置workspace/temp_info/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>
配置workspace/temp_info/conf/schema.xml添加
<field name="temp_id" type="string" indexed="true" stored="true" multiValued="false" />
<field name="temp_name" type="string" indexed="true" stored="true" />
<field name="temp_phone" type="string" indexed="true" stored="true" />
注释掉
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
修改
<uniqueKey>id</uniqueKey>
为
<uniqueKey>temp_id</uniqueKey>
增加文件workspace/temp_info/conf/data-config.xml文件内容为
<?xml version="1.0" encoding="utf-8"?>
<dataConfig>
<dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://ip:3306/test?useUnicode=true&characterEncoding=utf-8" temp="name" password="password"/>
<document >
<entity name="parteam_test_temp" pk="temp_id" query="select a.temp_id as temp_id,a.nick_name as temp_name from temp_info a">
<field column="temp_id" name="temp_id" />
<field column="temp_name" name="temp_name" />
</entity>
</document>
</dataConfig>
相关文章推荐
- Redis HyperLogLog
- POJ3126 - Prime Path
- 简单的调用第三方XlistView的上拉加载下拉刷新
- js判断打开设备
- 如何将下载的谷歌卫星地图导出成多张等份大图
- 湘潭oj 1247 Pair-Pair
- docker命令详解
- (LeetCode)Contains Duplicate II --- 查找重复的元素升级版
- Linux命令(16)压缩,解压文件
- 使用GPIO模拟I2C总线进行通信
- windows 8.1 windows 10 自动应答文件的创建
- 运维日记006 - vim操作总结(二、常用命令)
- fork函数与vfork函数
- [转]HTTP 头部详细解释
- 七.闭包
- Redis 有序集合(sorted set)
- easyui treegrid动态加载树形列表
- XML(PULL)解析文件
- 常量文件的写法-- UIKIT_EXTERN
- ThinkPHP官网瀑布流实现分享