solr dataimport
solrconfig.xml
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">data-config.xml</str>
<str name="df">text</str>
</lst>
</requestHandler>
solrconfig.xml同一个目录下增加 data-config.xml 文件
<dataConfig>
<dataSource type="JdbcDataSource" name="ds-1"
driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://localhost;databaseName=My_DB;responseBuffering=adaptive;"
user="you name"
password="you password"/>
<dataSource type="JdbcDataSource" name="ds-2"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://db2-host/dbname"
user="db_username"
password="db_password"/>
<dataSource type="FileDataSource" name="ds-3" encoding="UTF-8" /> <document>
<!--add filed for match sql column to solr column-->
<entity name="product" dataSource="ds-1"
query="select top 1 * from Product"
transformer="RegexTransformer,DateFormatTransformer" >
<field column="Id" name="id"/>
<entity name="productCategory" dataSource="ds-1"
query="select top 1 * from Code_Category_Product
Where Id=${product.CategoryId}">
<field column="Id" name="categoryid"/>
<field column="Description" name="category"/>
</entity>
<field column="Name" name="name" />
<field column="Description" name="description" />
<field column="UnitPrice" name="unitprice"/>
<field column="Status" name="status"/>
<field column="CreatedTime" name="createdtime" dateTimeFormat="M/d/yyyy h:m:s a"/>
<field column="Name" regex=".*Product1" name="name_py" />
</entity> <!--atch sql column to solr column in the sql query-->
<entity name="product2" dataSource="ds-1"
query="select Id as id,
CategoryId,
Name as name,
Description as description,
UnitPrice as unitprice,
Status as status,
CreatedTime as createdTime from Product
Where Id=10000000002">
<entity name="productCategory" dataSource="ds-1"
query="select top 1 * from Code_Category_Product
Where Id=${product2.CategoryId}">
<field column="Id" name="categoryid"/>
<field column="Description" name="category"/>
</entity>
</entity> <entity name="product3" dataSource="ds-3"
processor="XPathEntityProcessor"
stream="true"
forEach="/products/product | /products/item"
url="D:\Solr\solr-NewRMS\example\conf\products.xml"
transformer="RegexTransformer,DateFormatTransformer" >
<field column="id" xpath="/products/product/id" />
<field column="name" xpath="/products/product/@name" />
<field column="name_py" xpath="/products/product/name_py" />
<field column="createdtime" xpath="/products/product/createdtime" dateTimeFormat="yyyy-MM-dd'T'hh:mm:ss'Z'" />
<field column="tag" xpath="/products/product/tag" splitBy=","/>
<field column="description" regex="/products/product/description" />
</entity> </document>
</dataConfig>
data-config.xml同一个目录下增加 products.xml
<products>
<product name="product1001">
<id>1001</id>
<createdtime>2011-11-07T17:05:14</createdtime>
<description><![CDATA[this is 1001 desc]]></description>
<tag>tag11,tag22</tag>
</product>
<product name="product1002">
<id>1002</id>
<name_py>是</name_py>
<createdtime>2012-11-07T17:05:14</createdtime>
<description><![CDATA[this is 1002 description]]></description>
<tag>tag1</tag>
<tag>tag2</tag>
</product>
</products>
数据库:Product


如果不想把之前的数据清除 取消 Clean 选项
在Entity中选择运行项
点击Execute, 一段时间后点击Refresh Status查看运行结果
可以去Query中查看是否已经插入数据

solr dataimport的更多相关文章
- Solr学习笔记之3、Solr dataimport - 从SQLServer导入数据建立索引
Solr学习笔记之3.Solr导入SQLServer数据建立索引 一.下载MSSQLServer的JDBC驱动 下载:Microsoft JDBC Driver 4.0 for SQL Server ...
- 威胁快报|Solr dataimport成挖矿团伙新型利用方式
概述 近日,阿里云安全团队监测到挖矿团伙利用solr dataimport RCE(CVE-2019-0193)作为新的攻击方式对云上主机进行攻击,攻击成功后下载门罗币挖矿程序进行牟利.该团伙使用的恶 ...
- Solr Dataimport配置
参考资料: https://cwiki.apache.org/confluence/display/solr/Uploading+Structured+Data+Store+Data+with+the ...
- solr dataimport中遇到的问题
1.windows的tomcat是没有catalina.out的,可以通过修改start.bat和catalina.bat的方式让日志输出到catalina.out 2.按照网上搜到的资料配置好sol ...
- Linux下安装使用Solr
Linux下安装使用Solr 1.首先下载Solr.mmseg4j分词包.tomcat并解压,这用google.百度都可以搜索得到下载地址. 2.因为要使用到中文分词,所以要设置编码,进入tomcat ...
- solr连接数据库配置
一般要搜索的信息都是被存储在数据库里面的,但是我们不能直接搜数据库,所以只有借助Solr将要搜索的信息在搜索服务器上进行索引,然后在客户端供客户使用. 一.链接数据库 1. SQL配置 拿SQL Se ...
- 将数据库表导入到solr索引
将数据库表导入到solr索引 编辑solrcofnig.xml添加处理器 <requestHandler name="/dataimport" class="org ...
- solr导入mysql数据库
感谢ITeye的博主viskyzz分享的经验,笔者基本参考ta的方法.然而,解决中间出现的问题时也融入了自己的经验. 查看ta的原文请戳: http://tbwuming.iteye.com/blog ...
- SOLR (全文检索)
SOLR (全文检索) http://sinykk.iteye.com/ 1. 什么是SOLR 官方网站 http://wiki.apache.org/solr http://wiki.apach ...
随机推荐
- Could not find iPhone X simulator
Could not find iPhone X simulator Error: Could not find iPhone X simulator at resolve (/Users/zhouen ...
- html_entity_decode与htmlentities函数
htmlentities() 函数把字符转换为 HTML 实体.html_entity_decode() 函数把 HTML 实体转换为字符.例子:$a = '<div> <p> ...
- Python网络编程(一)
最近在啃<python核心编程(第三版)>,感觉这本书并不是特别的友好,虽然有基于python3提出的改进代码:但是整书的基准感觉还是在python2.7.所以python3的代码中还是有 ...
- APP测试常见功能测试点汇总
本文总结了一些APP功能测试中经常遇见测试点,仅供参考,是好早以前看哪位前辈总结的,一直在使用,所以也稍微的修改了下放到自己的博客中,以备日后温习.1.安装和卸载安装和卸载是任何一款APP中都属于最基 ...
- jquery——事件冒泡、事件委托
一个事件冒泡的例子: <!DOCTYPE html> <html lang="en"> <head> <meta charset=&quo ...
- 图片的回显。js
l <tr><td></td> <td> <c:if test="${editVo.pic!=''}"><img ...
- cgkib动态代理详解-不依赖接口,速度快
1. cglib原理-不依赖接口,速度快 使用ASM字节框架动态生成要代理类的子类,子类重写final以外的方法,织入横切逻辑 2. 示例-实现MethodInterceptor Test.java ...
- Java中的while循环——通过示例学习Java编程(10)
作者:CHAITANYA SINGH 来源:https://www.koofun.com/pro/kfpostsdetail?kfpostsid=20 在上一个教程中,我们讨论了for循环的用法.在本 ...
- OpenStack Ocata Telemetry 数据收集服务
1 安装配置计算服务 在所有计算节点上: 1.1 安装配置组件 安装包: # yum install -y openstack-ceilometer-compute 编辑配置文件/etc/ceilom ...
- Int与String之间相互转换
1 如何将字串 String 转换成整数 int? A. 有两个方法: 1). int i = Integer.parseInt([String]); 或 i = Integer.parseInt([ ...