mysql - SOLR-delta 导入不起作用,但完全导入工作正常

标签 mysql solr

我使用的是 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 &gt; '${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/

相关文章:

drupal - drupal View 中的自定义查询 - 现在无法排序

mysql - 根据列数据查找缺失行-MySQL

php - 为什么我在 Wordpress 中的 AJAX 请求不起作用

php - 如何在选择查询中获取 2 个表中的列值?

mongodb - MongoDB免费文本搜索和突出显示

mysql - 如何同步开发和生产数据库

java - 如何解决 NoSuchMethodError :EdgeNGramTokenFilter

java - Solr 多核搜索

node.js - 逻辑分离 : Search, 数据库和应用程序

solr - 如何在 lucene 中增强更长的文档