系列教程
solr6.3与MySQL结合使用的简明教程(一)
solr6.3与MySQL结合使用的简明教程(二)
solr6.3与MySQL结合使用的简明教程(三)——SolrException: undefined field text错误如何解决
solr6.3与MySQL结合使用的简明教程(四)
solr6.3与MySQL结合使用的简明教程(五)——中文分词
补充:
1、参考 https://blog.youkuaiyun.com/erhei0317/article/details/52663436
data-config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/django_blog"
user="root"
password=""/>
<document name="blog">
<entity name="blog_blog" pk="id"
query="select id,title,content from blog_blog"
deltaImportQuery="select id,title,content from blog_blog where ID='${dataimporter.delta.id}'"
deltaQuery="select id from blog_blog where add_time > '${dataimporter.last_index_time}'"
deletedPkQuery="select id from blog_blog where id=0">
<field column="id" name="id" />
<field column="title" name="title" />
<field column="content" name="content"/>
</entity>
</document>
</dataConfig>
query 用于初次导入到索引的sql语句。
考虑到数据表中的数据量非常大,比如千万级,不可能一次索引完,
因此需要分批次完成,那么查询语句query要设置两个参数:
${dataimporter.request.length}
${dataimporter.request.offset}
query=”select id,title,content from blog_blog limit ${dataimporter.request.length}
offset ${dataimporter.request.offset}”
请求:http://localhost:8983/solr/collection2/dataimport?
command=full-import&commit=true&clean=false&offset=0&length=10000
deltaImportQuery 根据ID取得需要进入的索引的单条数据。
deltaQuery 用于增量索引的sql语句,用于取得需要增量索引的ID。
deletedPkQuery 用于取出需要从索引中删除文档的的ID
注意在schema.xml中文分词器的配置:
<!-- IKAnalyzer-->
<fieldType name="text_ik" class="solr.TextField">
<analyzer class="org.wltea.analyzer.lucene.IKAnalyzer"/>
</fieldType>
2、full-import 全量导入,delta-import-增量导入
3、solr data-config.xml配置的详细介绍
https://blog.youkuaiyun.com/boolbo/article/details/50352331
4、Solr配置文件schema.xml和solrconfig.xml分析
https://blog.youkuaiyun.com/liuweitoo/article/details/8137124