SOLR-delta 导入不起作用,但完全导入工作正常 [英] SOLR-delta import does not working but full import working fine
问题描述
我正在使用 solr 4.10.2,因为完全导入工作正常,但如果在 mysql 数据库中有任何插入/更新,增量导入就无法正常工作.Delta 导入不会出现任何错误,但不会获取任何更改.
I am using solr 4.10.2 in that full import works fine but somehow delta import doesn't working if any insert/update in mysql DB. Delta import does not give any error but never fetches any changes.
我按照本网站中提到的步骤操作
I followed the steps mentioned in this site
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"/>
推荐答案
代替 '${dataimporter.last_index_time}' 使用 '${dih.last_index_time}' OR STR_TO_DATE('${dih.last_index_time}','%Y-%m-%d %H:%i:%s')
Instead of '${dataimporter.last_index_time}' use '${dih.last_index_time}' OR STR_TO_DATE('${dih.last_index_time}','%Y-%m-%d %H:%i:%s')
我使用如下,因为我的 MYSQL 字段 updated_at
是 varchar.
I am using like below because my MYSQL field updated_at
is 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')
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')
这篇关于SOLR-delta 导入不起作用,但完全导入工作正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!