<dataConfig><!--- 此段話配置的是一個(gè)MySQL的數(shù)據(jù)源,(數(shù)據(jù)源也可以配置在solrconfig.xml中) ---><dataSource name="mydb" type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/test" user="root" password="ninemax"/><document><!-- 下面分別來(lái)介紹屬性(如有錯(cuò)誤,歡迎指出) --><!-- pk="ID" 這個(gè)很有必要,因?yàn)槠渲械脑隽克饕樵冎麈IID時(shí)需要 --><!-- dataSource="mydb" 這個(gè)引用名字是引用上面數(shù)據(jù)源的名字 --><!-- name="myinfo" 這個(gè)名字必須唯一,存在多個(gè)實(shí)體時(shí) --><!-- query="select * from myinfo WHERE isdelete=0 query查詢是指查詢出表里所有的符合條件的數(shù)據(jù),因?yàn)楣P者測(cè)試的有刪除業(yè)務(wù),所以where 后面有一個(gè)限定條件isdelete=0,意思為查詢未被刪除的數(shù)據(jù)(注意這個(gè)query查詢只對(duì)第一次全量導(dǎo)入有作用,對(duì)增量導(dǎo)入不起作用)--><!--deltaQuery="select ID from myinfo where my_date > '${dataimporter.last_index_time}'" deltaQuery的意思是,查詢出所有經(jīng)過(guò)修改的記錄的ID可能是修改操作,添加操作,刪除操作產(chǎn)生的(此查詢只對(duì)增量導(dǎo)入起作用,而且只能返回ID值)--><!--deletedPkQuery="select ID from myinfo where isdelete=1" 此操作值查詢那些數(shù)據(jù)庫(kù)里偽刪除的數(shù)據(jù)的ID(即isdelete標(biāo)識(shí)為1的數(shù)據(jù))solr通過(guò)它來(lái)刪除索引里面對(duì)應(yīng)的數(shù)據(jù)(此查詢只對(duì)增量導(dǎo)入起作用,而且只能返回ID值)--><!--deltaImportQuery="select * from myinfo where ID='${dataimporter.delta.ID}'"次查詢是獲取以上兩步的ID,然后把其全部數(shù)據(jù)獲取,根據(jù)獲取的數(shù)據(jù)對(duì)索引庫(kù)進(jìn)行更新操作,可能是刪除,添加,修改(此查詢只對(duì)增量導(dǎo)入起作用,可以返回多個(gè)字段的值,一般情況下,都是返回所有字段的列)--><entity pk="ID" dataSource="mydb" name="myinfo" query="select * from myinfo WHERE isdelete=0 " deltaQuery="select ID from myinfo where my_date > '${dataimporter.last_index_time}'" deletedPkQuery="select ID from myinfo where isdelete=1" deltaImportQuery="select * from myinfo where ID='${dataimporter.delta.ID}'"><!-- 此條記錄有必要說(shuō)一下,ID指定大寫(xiě)的,與上面語(yǔ)句中的對(duì)應(yīng)起來(lái)----><field column="ID" name="id"/><field column="name" name="name"/><field column="address" name="address"/><field column="age" name="age"/><field column="my_date" name="my_date"/><field column="isdelete" name="isdelete"/></entity></document></dataConfig>