Lucene之Solr导入数据库中的数据(九)
2017-04-01 11:42
417 查看
一、介绍
1. 找到我们的solrHome的位置, 并且知道其中的一个collection,如下:2. 将下面的两个jar包放在lib目录下面:
3. 将数据库的驱动包也放在lib目录下面:
4. 配置solrconfig.xml文件,添加一个requestHandler。
在E:\temp\solrhome\collection1\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>
5. 创建一个data-config.xml,保存到collection1\conf\目录下:
<?xml version="1.0" encoding="UTF-8" ?>
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/lucene"
user="root"
password="root"/>
<document>
<entity name="product" query="SELECT pid,name,catalog_name,price,description,picture FROM products ">
<field column="pid" name="id"/>
<field column="name" name="product_name"/>
<field column="catalog_name" name="product_catalog_name"/>
<field column="price" name="product_price"/>
<field column="description" name="product_description"/>
<field column="picture" name="product_picture"/>
</entity>
</document>
</dataConfig>
6. 在collection1\conf目录下,找到schema.xml,在里面添加配置:
<field name="product_name" type="string" indexed="true" stored="true"></field>
<field name="product_price" type="float" indexed="true" stored="true"></field>
<field name="product_description" type="string" indexed="true" stored="false"></field>
<field name="product_catalog_name" type="string" indexed="true" stored="true"></field>
<field name="product_picture" type="string" indexed="false" stored="true"></field>
7. 重启tomcat.
8. 点击“execute”按钮导入数据。
导入数据前会先清空索引库,然后再导入。
相关文章推荐
- Solr从数据库导入数据(DIH)
- 利用SOLR搭建企业搜索平台 之十(数据库数据导入到solr)
- Solr从数据库导入数据(DIH)
- Solr之关系型数据库导入数据
- solr运行配置与数据库数据导入到solr
- solr进阶三:从数据库中导入数据到solr
- solr运行配置与数据库数据导入到solr
- 将数据库的数据导入solr索引库中
- win 下 solr 链接数据库并把数据导入到solr中
- solr导入数据库数据
- solr导入数据库数据-tinyint数据转boolean
- Solr从数据库导入数据
- 【转】Solr从数据库导入数据(DIH)
- solr运行配置与数据库数据导入到solr
- solr学习之(五)_solr4.2.0中从数据库中导入数据到索引
- Solr1.4.0源码分析(一) 解决DataImportHandler从数据库导入大量数据而内存溢出的问题
- (七) solr数据导入:通过JDBC从数据库导入数据
- 从数据库中往solr中导入数据之1
- solr导入数据库数据
- solr导入数据库数据