在配置好与MYSQL的数据源基础上,做增量更新索引,总结如下
1.data-config.xml内容修改为
<dataConfig>
<dataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/demo" user="root" password=""/>
<document name="products">
<entity name="item" pk="id"
query="SELECT id,title,contents,last_index_time FROM solr_articles"
deltaImportQuery="SELECT id,title,contents,last_index_time FROM solr_articles
WHERE id = '${dataimporter.delta.id}'"
deltaQuery="SELECT id FROM solr_articles
WHERE last_index_time > '${dataimporter.last_index_time}'">
</entity>
</document>
</dataConfig>
<dataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/demo" user="root" password=""/>
<document name="products">
<entity name="item" pk="id"
query="SELECT id,title,contents,last_index_time FROM solr_articles"
deltaImportQuery="SELECT id,title,contents,last_index_time FROM solr_articles
WHERE id = '${dataimporter.delta.id}'"
deltaQuery="SELECT id FROM solr_articles
WHERE last_index_time > '${dataimporter.last_index_time}'">
</entity>
</document>
</dataConfig>
更新成功之后,conf/dataimport.properties时间会改变
3.通过对http://localhost:8080/solr/dataimport?command=delta-import定时请求达到定时增量更新索引目的