一:相关参考文档
二:介绍
1 2
| 前几篇介绍的同步数据都是进行full-import(全量更新),本篇将进行增量更新数据, 新创建了一个db_product的core进行演示。
|
三:创建db_product
1
| 关于如何创建新的db_product,该篇不做阐述,不懂得可以参考其他文章
|
四:配置增量更新
1 2
| db-data-config.xml的基本配置和db_core的配置一样,唯一不同的就是要使用deltaImportQuery和deltaQuery, 具体的配置如下:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| <dataConfig> <dataSource driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://localhost:51216;DatabaseName=db_solr" user="sa" password="EIKYJnnifZgBRMa0" /> <document> <entity name="Product" pk="id" transformer="RegexTransformer" query="select * from solr_product;" deltaImportQuery="SELECT * from solr_product where id = '${dataimporter.delta.id}'" deltaQuery="SELECT id from solr_product where update_time > '${dataimporter.last_index_time}';"> <field column="id" name="id" /> <field column="product_name" name="productName" /> <field column="product_desc" name="productName" /> <field column="insert_time" name="insertTime" /> <field column="update_time" name="updateTime" /> </entity> </document> </dataConfig>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| <fieldType name="text_ik" class="solr.TextField"> <analyzer type="index" useSmart="false" class="org.wltea.analyzer.lucene.IKAnalyzer"/> <analyzer type="query" useSmart="false" class="org.wltea.analyzer.lucene.IKAnalyzer"/> </fieldType>
<uniqueKey>id</uniqueKey> <field name="productName" type="string" indexed="true" stored="true" /> <field name="productDesc" type="string" indexed="true" stored="true" /> <field name="insertTime" type="pdate" indexed="true" stored="true" /> <field name="updateTime" type="pdate" indexed="true" stored="true" />
<field name="keyword" type="text_ik" indexed="true" stored="true" omitNorms="true" multiValued="true"/> <copyField source="id" dest="keyword" maxChars="30000"/> <copyField source="productName" dest="keyword" maxChars="30000"/> <copyField source="productDesc" dest="keyword" maxChars="30000"/>
|
1 2 3
| db_product和db_core的配置基本一样,区别有两点: 1.db_core用的表是solr_person,db_product用的表是solr_product 2.db-data-config.xml配置不一样,db_product增加了deltaImportQuery和deltaQuery的配置
|
五:admin ui
*************感谢您的阅读*************