我使用的是 solr 4.10.2,完全导入工作正常,但如果在 mysql 数据库中有任何插入/更新,delta 导入将无法正常工作。 Delta 导入不会给出任何错误,但不会获取任何更改。
我遵循了本网站中提到的步骤
http://wiki.apache.org/solr/DataImportHandler
data-config.xml
<dataConfig>
<dataSource autoCommit="true" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/delta_import_handler" user="root" password="Gemini*123" />
<document name="Products">
<entity name="item" pk="ID" query="SELECT * FROM item " deltaImportQuery="select * from item where ID='${dih.delta.ID}'"
deltaQuery="select id from item where last_modified > '${dataimporter.last_index_time}'">
<field name="ID" column="id"/>
<field name="name" column="name"/>
<field name="manu" column="manu"/>
<field name="weight" column="weight"/>
<field name="price" column="price"/>
<field name="popularity" column="popularity"/>
<field name="includes" column="includes"/>
<field name="last_modified" column="last_modified" />
solrconfig.xml
<requestHandler name="/dataimport"class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">data-config.xml</str>
</lst>
</requestHandler>
schema.xml
<field name="id" type="text_general" indexed="true" stored="true"/>
<field name="name1" type="string" indexed="true" stored="true"/>
<field name="manu" type="string" indexed="true" stored="true"/>
<field name="weight" type="string" indexed="true" stored="true"/>
<field name="price" type="string" indexed="true" stored="true"/>
<field name="popularity" type="string" indexed="true" stored="true"/>
<field name="includes" type="string" indexed="true" stored="true"/>
<field name="last_modified" type="timestamp" indexed="true" stored="true"/>
最佳答案
使用“${dih.last_index_time}”代替“${dataimporter.last_index_time}”或 STR_TO_DATE('${dih.last_index_time}','%Y-%m-%d %H:%i:% s')
我像下面这样使用,因为我的 MYSQL 字段 updated_at
是 varchar。
STR_TO_DATE(updated_at,'%Y-%m-%dT%H:%i:%s.000Z') > STR_TO_DATE('${dih.last_index_time}','%Y-%m-%d % H:%i:%s')
关于mysql - SOLR-delta 导入不起作用,但完全导入工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31110290/