一、踩坑:
1、tomcat需使用tomcat8,用7会有很多莫名其妙的错误。如admin ui页面,各种css、js资源404。。还有logging页面,各种java异常提示,servlet api方法不存在等等。
JDK1.8版本以上。
2、新版本的solr,schema.xml采用managed-schem文件,增加filed、fieldType直接在该文件中修改。
二、全量、增量mysql索引
1、solrconfig.xml:
“/select”上方增加:
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">data-config.xml</str>
</lst>
</requestHandler>
如下图:
2、conf目录增加data-config.xml文件,内容如下(与solr5个别地方不太一样,如dataimporter):
<dataConfig>
<dataSource name="jdbcDataSource" type="JdbcDataSource" driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:3307/dbName?useUnicode=true&characterEncoding=utf-8" user="user" password="password"/>
<document name="product">
<entity dataSource="jdbcDataSource" name="product"
query="select id,name,description from product"
deltaQuery="select id from product where ts > '${dataimporter.last_index_time}'"
deltaImportQuery="select id,name,description from product where id= ${dataimporter.delta.id}">
<field column="id" name="id"/>
<field column="name" name="name"/>
<field column="description" name="description"/>
</entity>
</document>
</dataConfig>
如图:
3、entity下拉框选择对应entity,增量时需反选clean。Processed若为0,可以看logging页异常提示。
PS:更复杂的库表,可以参考"solr-6.1.0/example/example-DIH/solr/db/conf/db-data-config.xml".