1 导入需要的驱动文件
2 在solrconfig.xml文件中添加
<!-- -->
<requestHandler name="/dataimport"
class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">data-config.xml</str>
</lst>
</requestHandler>
3 在同级目录下建立data-config.xml文件
4 在data-config.xml文件中添加数据库配置
<?xml version="1.0" encoding="UTF-8" ?>
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://129.0.0.1:3306/alphago_xj_1018_2"
user="root"
password="shiye"/>
<document>
<entity name="persionSHI"
query="SELECT id,pr_name,pr_ethnic,pr_education,pr_jobcareer FROM ag_prisoner">
<field column="id" name="id" />
<field column="pr_name" name="prName" />
<field column="pr_ethnic" name="prEthnic"/>
<field column="pr_education"name="prEducation"/>
<field column="pr_jobcareer"name="prJobcareer"/>
</entity>
</document>
</dataConfig>
5 在schema.xml文件中添加 上面对应的那么的配置
<!--field-->
<field name="prName" type="string" indexed="true" stored="true"/>
<field name="prEthnic" type="text_ik" indexed="true" stored="true"/>
<field name="prEducation" type="text_ik" indexed="true" stored="true"/>
<field name="prJobcareer" type="string" indexed="true" stored="true"/>
<!---->
<field name="persion_keywords" type="text_ik" indexed="true" stored="true" multiValued="true"/>
<copyField source="prName" dest="persion_keywords"/>
<copyField source="prJobcareer" dest="persion_keywords"/>