1.data-config.xml配置增量执行语句
<?xml version="1.0" encoding="UTF-8" ?>
<dataConfig>
<dataSource name="source_hinew" type="JdbcDataSource" driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/solr_test?serverTimezone=UTC&useUnicode=true&autoReconnect=true&characterEncoding=UTF-8"
user="test" password="test"/>
<document>
<entity name="member" pk="memid" >
query="select distinct * from member"
deltaQuery="select memid from member
where mem_date_updated > '${dataimporter.last_index_time}'"
deltaImportQuery="select memid from member
where mem_date_updated > '${dataimporter.last_index_time}'">
<field column="memid" name="memid" />
<field column="name" name="name" />
<field column="mem_first_name" name="mem_first_name" />
<field column="mem_last_name" name="mem_last_name" />
<field column="mem_org_title" name="mem_org_title" />
<field column="mem_org_dept" name="mem_org_dept" />
<field column="mem_job_func" name="mem_job_func" />
<field column="mem_job_level" name="mem_job_level" />
<field column="mem_add_city" name="mem_add_city" />
<field column="mem_add_state_code" name="mem_add_state_code" />
<field column="mem_add_country_code" name="mem_add_country_code" />
<field column="mem_date_created" name="mem_date_created" />
<field column="mem_email" name="mem_email" />
<field column="mem_orgid" name="mem_orgid" />
<field column="mem_add_address" name="mem_add_address" />
</entity>
</document>
</dataConfig>
delta-import:通过deltaQuery,查到数据库中未被索引记录的ids(id1,id2...),然后执行deltaImportQuery,如果没用deltaImportQuery,就通过Query去组装deltaImportQuery。对于上面的配置文件,就应该组装成这样的query:select distinct * from member where memid = id1,把这条记录导入索引库里面,然后再导id2。曾以为solr应该组装select .. from .. where .. and memid in (id1, id2)这样的query,可好像它并没这样做。