1.在solrhome/rsm/conf/solrconfig.xml中进行如下配置
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">t_rsm.xml</str>
</lst>
</requestHandler>
加载配置新建的与数据库建立关系的配置
注:t_rsm.xml与solrconfig.xml在同一目录下
2.t_rsm.xml写入数据库连接地址,和要索引的字段
<dataConfig>
<dataSource name="jdbc" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/rencai" user="root"
password="root" />
<document>
<entity name="rsm_resume" pk="id"
query="select resumeID as id,resumeName,job,experience,education,rsmstatus,salary,sex,location,district,subway,objvalue,subjvalue,selfvalue,skill,updatetime,leixing,place,updateUser,resumeTime,content2 from rsm_resume"
deltaQuery="select resumeID as id,resumeName,job,experience,education,rsmstatus,salary,sex,location,district,subway,objvalue,subjvalue,selfvalue,skill,updateTime,leixing,place,updateUser,resumeTime,content2 from rsm_resume where updatetime > '${dataimporter.last_index_time}' "
deltaImportQuery="select resumeID as id,resumeName,job,experience,education,rsmstatus,salary,sex,location,district,subway,objvalue,subjvalue,selfvalue,skill,updatetime,leixing,place,updateUser,resumeTime,content2 from rsm_resume where resumeID = '${dataimporter.delta.id}' ">
<field column="resmeID" name="id" />
<field column="resumeName" name="Resumename" />
<field column="job" name="Job" />
<field column="experience" name="Experience" />
<field column="education" name="Education" />
<field column="rsmstatus" name="Rsmstatus" />
<field column="salary" name="Salary" />
<field column="sex" name="Sex" />
<field column="location" name="Location" />
<field column="district" name="District" />
<field column="subway" name="Subway" />
<field column="objvalue" name="Objvalue" />
<field column="subjvalue" name="Subjvalue" />
<field column="selfvalue" name="Selfvalue" />
<field column="skill" name="Skill" />
<field column="updatetime" name="Updatetime" />
<field column="leixing" name="Leixing" />
<field column="place" name="Place" />
<field column="updateUser" name="UpdateUser" />
<field column="resumeTime" name="ResumeTime" />
<field column="content2" name="Content2" />
</entity>
</document>
</dataConfig>
3.在和solrconfig.xml同目录下的schema.xml中配置索引字段的数据类型
<field name="Updatetime" type="date" indexed="true" stored="true" />
<field name="Resumename" type="text_general" indexed="true" stored="true" />
<field name="Job" type="text_general" indexed="true" stored="true" />
<field name="Salary" type="text_general" indexed="true" stored="true" />
<field name="Experience" type="int" indexed="true" stored="true" />
<field name="Education" type="text_general" indexed="true" stored="true" />
<field name="Sex" type="text_general" indexed="true" stored="true" />
<field name="Location" type="text_general" indexed="true" stored="true" />
<field name="District" type="text_general" stored="true" />
<field name="Subway" type="text_general" indexed="true" stored="true" />
<field name="Objvalue" type="text_general" indexed="true" stored="true" />
<field name="Subjvalue" type="text_general" indexed="true" stored="true" />
<field name="Rsmstatus" type="text_general" indexed="true" stored="true" />
<field name="Leixing" type="int" indexed="true" stored="true" />
<field name="Place" type="text_general" indexed="true" stored="true" />
<field name="UpdateUser" type="text_general" indexed="true" stored="true" />
<field name="ResumeTime" type="date" indexed="true" stored="true" />
<field name="Content2" type="text_general" indexed="true" stored="true" />
<field name="Selfvalue" type="text_general" indexed="true" stored="false" />
<field name="Skill" type="text_general" indexed="true" stored="false" />
<field name="Createtime" type="date" indexed="true" stored="false" />
<field name="Software" type="text_general" indexed="true" stored="false" />
<field name="Hardware" type="text_general" indexed="true" stored="false" />
<field name="Tools" type="text_general" indexed="true" stored="false" />
<field name="Duty" type="text_general" indexed="true" stored="false" />
<field name="Projdetail" type="text_general" indexed="true" stored="false" />
<field name="Valuespec" type="text_general" indexed="true" stored="false" />
<field name="Experdetail" type="text_general" indexed="true" stored="false" />
使用时发送url:http://localhost:8080/solr/new_core/dataimport?command=full-import&commit=true&clean=true
到此solr的全量更新配置就完成了