scheme.xml
<?xml version="1.0" encoding="UTF-8" ?>
<schema name="test" version="1.4">
<types>
<fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
<!-- in this example, we will only use synonyms at query time
<filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
-->
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<fieldType name="text_cn" class="solr.TextField">
<analyzer class="org.wltea.analyzer.lucene.IKAnalyzer"></analyzer> #IKAnalyzer分词
</fieldType>
</types>
<fields>
<field name="id" type="int" indexed="true" stored="true" required="true" />
<field name="title" type="text_cn" indexed="true" stored="true"/>
<field name="_version_" type="long" indexed="true" stored="true"/>
</fields>
<uniqueKey>id</uniqueKey>
<defaultSearchField>title</defaultSearchField>
<solrQueryParser defaultOperator="AND"/>
</schema>
solrconfig.xml 增加 dataimport
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults" >
<str name="config">data-config.xml</str>
</lst >
</requestHandler >
data-config.xml 配置数据源
<dataConfig>
<dataSource type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:3306/test"
user="test"
password="test"/>
<document>
<entity name="news"
query="SELECT id,title,news_url,news_type,website,img_size,img_url,news_time,page_level,created,description,hits,seq FROM news"
deltaImportQuery="SELECT id,title,news_url,news_type,website,img_size,img_url,news_time,page_level,created,description,hits,seq FROM news where id='${dataimporter.delta.id}'"
deltaQuery="select id from news where `news_time` > '${dataimporter.last_index_time}'"> #配置增量数据源
>
</entity>
</document>
</dataConfig>