/home/solr_home/collection1/下面:
data-config.xml:
<dataConfig>
<dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://192.168.1.1:3306/huizhan" user="dx" password="U7*h3<9#!j"/>
<document name="userDoc">
<entity name="user" query="select id,company,key_word,username from ex_user" >
<field name="id" column="id" />
<field name="company" column="company" />
<field name="key_word" column="key_word" />
<field name="username" column="username" />
</entity>
</document>
</dataConfig>
schema.xml:
需要配上字段名:
<field name="username" type="text_general" stored="true"/>
<field name="company" type="text_general" stored="true"/>
<field name="key_word" type="text_general" stored="true"/>
solrconfig.xml:
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">data-config.xml</str>
</lst>
</requestHandler>