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的更多相关文章

  1. Solr学习笔记之3、Solr dataimport - 从SQLServer导入数据建立索引

    Solr学习笔记之3.Solr导入SQLServer数据建立索引 一.下载MSSQLServer的JDBC驱动 下载:Microsoft JDBC Driver 4.0 for SQL Server ...

  2. 威胁快报|Solr dataimport成挖矿团伙新型利用方式

    概述 近日,阿里云安全团队监测到挖矿团伙利用solr dataimport RCE(CVE-2019-0193)作为新的攻击方式对云上主机进行攻击,攻击成功后下载门罗币挖矿程序进行牟利.该团伙使用的恶 ...

  3. Solr Dataimport配置

    参考资料: https://cwiki.apache.org/confluence/display/solr/Uploading+Structured+Data+Store+Data+with+the ...

  4. solr dataimport中遇到的问题

    1.windows的tomcat是没有catalina.out的,可以通过修改start.bat和catalina.bat的方式让日志输出到catalina.out 2.按照网上搜到的资料配置好sol ...

  5. Linux下安装使用Solr

    Linux下安装使用Solr 1.首先下载Solr.mmseg4j分词包.tomcat并解压,这用google.百度都可以搜索得到下载地址. 2.因为要使用到中文分词,所以要设置编码,进入tomcat ...

  6. solr连接数据库配置

    一般要搜索的信息都是被存储在数据库里面的,但是我们不能直接搜数据库,所以只有借助Solr将要搜索的信息在搜索服务器上进行索引,然后在客户端供客户使用. 一.链接数据库 1. SQL配置 拿SQL Se ...

  7. 将数据库表导入到solr索引

    将数据库表导入到solr索引 编辑solrcofnig.xml添加处理器 <requestHandler name="/dataimport" class="org ...

  8. solr导入mysql数据库

    感谢ITeye的博主viskyzz分享的经验,笔者基本参考ta的方法.然而,解决中间出现的问题时也融入了自己的经验. 查看ta的原文请戳: http://tbwuming.iteye.com/blog ...

  9. SOLR (全文检索)

    SOLR (全文检索) http://sinykk.iteye.com/ 1.   什么是SOLR 官方网站 http://wiki.apache.org/solr http://wiki.apach ...

随机推荐

  1. 洛谷P2746 校园网Network of Schools

    题目描述 一些学校连入一个电脑网络.那些学校已订立了协议:每个学校都会给其它的一些学校分发软件(称作"接受学校").注意即使 \(B\) 在 \(A\) 学校的分发列表中, \(A ...

  2. thinkphp5引入百度编辑器

    在ThinkPHP的模板(html文件)中引入Ueditor  下载ueditor解压至public/static目录 在需要的页面引入js文件 <script type="text/ ...

  3. js常见问题之为什么点击弹出的i总是最后一个

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. 08-图8 How Long Does It Take (25 分

    Given the relations of all the activities of a project, you are supposed to find the earliest comple ...

  5. 判断是pc端登录还是移动端登录

    java判断 https://blog.csdn.net/qq_32657581/article/details/71405838 https://zhidao.baidu.com/question/ ...

  6. 忘记mysql数据库密码时进行修改方法

    长时间没有使用数据库了,或者把密码改完之后就忘了数据库密码,不能正常进入数据库,也无法修改密码,有一个简单的常用修改密码方式: 1.首先找到和打开mysql.exe和mysqld.exe所在的文件夹( ...

  7. Vue 项目: npm run dev b报错 “'webpack-dev-server' 不是内部或外部命令,也不是可运行的程序 或批处理文件。”

    前提: 电脑已经安装了nodeJS和npm,  项目是直接下载的zip包. 报错步骤为1:cd /d 目录: 2. npm ren dev  -------> 报错如下: > webpac ...

  8. nginx图片缓存服务器配置实战

     1.图片目录设置: 假定服务器主目录为nginx的默认目录:/usr/local/nginx-0.8.32/html/ 图片存放目录为:/usr/local/nginx-0.8.32/html/SD ...

  9. koa2 从入门到进阶之路 (四)

    之前的文章我们介绍了一下 koa 中间件 以及 koa 中间件的洋葱图执行流程,本篇文章我们来看一下 koa 中使用 ejs 模板及页面渲染. 在 Express 中,我们经常会用 ejs 模板来渲染 ...

  10. 开源分布式Job系统,调度与业务分离-如何创建一个计划HttpJob任务

    项目介绍: Hangfire:是一个开源的job调度系统,支持分布式JOB!! Hangfire.HttpJob 是我针对Hangfire开发的一个组件,该组件和Hangfire本身是独立的.可以独立 ...