简体   繁体   中英

SOLR-delta import does not working but full import working fine

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 &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"/>

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')

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')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM