昨天做了solr 的基础安装, 今天学习与数据库(MySQL)的集成
1, 首先当然是把MySQL的jar包加入.
2. 建立User表,此处就一个ID, 一个username , 然后配置索引文件 mysql-data.xml.
<?xml version="1.0" encoding="UTF-8"?>
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/mydatabase"
user="user"
password="password"/>
<document name="user">
<entity name="user"
query="select * from user"
deltaImportQuery="SELECT * FROM `user` WHERE id='${dataimporter.delta.job_jobs_id}'"
deltaQuery="SELECT id FROM `user` WHERE id > '${dataimporter.last_index}'">
<field column="id" name="id" />
<field column="username" name="username" />
</entity>
</document>
</dataConfig>
** query 全表索引语句, deltaQuery 增量索引语句, field 表中对应字段
3. 在collection1/conf/solrconf.xml 中 在相似位置加入上面的配置文件
<requestHandler name="/dataimport" class="solr.DataImportHandler">
<lst name="defaults">
<str name="config">mysql-data.xml</str>
</lst>
</requestHandler>
注意 一定加上 <lib dir="solr/dist/" regex="solr-dataimporthandler-.*\.jar" /> 否则会报找不到类
4. 在 schema.xml 加上filed
<field name="id" type="text_general" indexed="true" stored="true"/> <!--ID 已存在则不用添加了-->
<field name="content" type="text_ik" indexed="true" stored="true"/>
5. 然后就可以启动servlet容器咯. 下图
6. 执行command full-import 就可以构建索引了.
相关推荐
Apache Solr 4 Cookbook Apache Solr 4 Cookbook Apache Solr 4 Cookbook Apache Solr 4 Cookbook Apache Solr 4 Cookbook
Solr笔记,Solr笔记,Solr笔记,Solr笔记,Solr笔记,Solr笔记,Solr笔记,Solr笔记,Solr笔记,Solr笔记,
Spring Data for Apache Solr API。 Spring Data for Apache Solr 开发文档
Solr学习笔记
Apache Solr for Indexing Data
apache solr搜索系统的.Net实现
Apache Solr Search
solr学习的关键命令使用说明,包括插入命令与查询命令
Apache Solr Essentials is a fast-paced guide to help you quickly learn the process of creating a scalable, efficient, and powerful search application. The book starts off by explaining the ...
apache solr 源文件 版本为3.6.1 让你能够更好地了解solr实现,更好的使用solr
Apache Solr 3 Enterprise Search Server 部分中文翻译 从博客上面保存下来的。是网页版,方便大家查看
apache solr 官方文档(英文原版) 包含详细的安装、Schema配置、solrConfig配置、管理页面使用等.
Apache Solr(solr-8.11.1.tgz)Binary releases 二进制版本
solr 学习必备,多看看吧!solr学习笔记,对于初学者不错的!来分享
Apache Solr(solr-8.11.1.zip)Binary releases 二进制版本
apache solr guide 4.7
《apachesolr7官方指南》