Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

delta import handler not working properly

Tags:

solr

dih

I followed the steps mentioned @: http://wiki.apache.org/solr/DataImportHandler

I also tried other solution from stackoverflow however still it is not working.

Problem is: I have configured Delta-import handler still every time I run it; it indexes all records from DB. I have 30 records in DB. and every time I run delta import it is indexing all 30 records. I want only those which are changed/deleted should be indexed.

Any quick help/pointer/solution to this issue is appreciated.


Data-config.xml

<dataConfig>
    <dataSource type="JdbcDataSource" name="ds-books" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/test" user="root" password=""/>
    <document name="books">
        <entity name="books" pk="id" query="select * from books" deltaImportQuery="SELECT * FROM books WHERE id = '${dataimporter.delta.id}'"  deltaQuery="SELECT  id FROM books WHERE last_modified &gt;  '${dataimporter.last_index_time}'" >
            <field column="id" name="id"  indexed="true" stored="true"/>
            <field column="NAME" name="name" />
            <field column="PRICE" name="price" />
        <field column="last_modified" name="last_modified" />
        </entity>
    </document>
</dataConfig>

Command that I am using to execute it is:

http://localhost:8983/solr/dataimport?command=delta-import

dataimport.properties file:

Fri May 10 17:13:18 IST 2013

last_index_time=2013-05-10 17\:13\:18

books.last_index_time=2013-05-10 17\:13\:18

dataimporter.last_index_time=2013-05-10 17\:11\:42


XML Response that I am getting is as follows:

 <response>
  <lst name="responseHeader">
      <int name="status">0</int>
      <int name="QTime">4</int>
      </lst>
      <lst name="initArgs">
          <lst name="defaults">
            <str name="config">data-config.xml</str>
          </lst>
        </lst>
  <str name="command">delta-import</str>
  <str name="status">idle</str>
  <str name="importResponse"/>
  <lst name="statusMessages">
      <str name="Total Requests made to DataSource">1</str>
      <str name="Total Rows Fetched">30</str>
      <str name="Total Documents Skipped">0</str>
      <str name="Delta Dump started">2013-05-10 17:13:17</str>
      <str name="Identifying Delta">2013-05-10 17:13:17</str>
      <str name="Deltas Obtained">2013-05-10 17:13:17</str>
      <str name="Building documents">2013-05-10 17:13:17</str>
      <str name="Total Changed Documents">30</str>
      <str name="">Indexing completed. Added/Updated: 30 documents. Deleted 0 documents.</str>
  <str name="Committed">2013-05-10 17:13:17</str>
  <str name="Total Documents Processed">30</str>
  <str name="Time taken">0:0:0.303</str></lst>
  <str name="WARNING">This response format is experimental.  It is likely to change in the future.</str>
  </response>

In Log file I am getting following thing:

INFO: Read dataimport.properties
May 10, 2013 5:13:18 PM org.apache.solr.handler.dataimport.DocBuilder doDelta
INFO: Starting delta collection.
May 10, 2013 5:13:18 PM org.apache.solr.handler.dataimport.DocBuilder collectDelta
INFO: Running ModifiedRowKey() for Entity: books
May 10, 2013 5:13:18 PM org.apache.solr.handler.dataimport.JdbcDataSource$1 call
INFO: Creating a connection for entity books with URL: jdbc:mysql://localhost/test
May 10, 2013 5:13:18 PM org.apache.solr.handler.dataimport.JdbcDataSource$1 call
INFO: Time taken for getConnection(): 9
May 10, 2013 5:13:18 PM org.apache.solr.handler.dataimport.DocBuilder collectDelta
INFO: Completed ModifiedRowKey for Entity: books rows obtained : 30
May 10, 2013 5:13:18 PM org.apache.solr.handler.dataimport.DocBuilder collectDelta
INFO: Completed DeletedRowKey for Entity: books rows obtained : 0
May 10, 2013 5:13:18 PM org.apache.solr.handler.dataimport.DocBuilder collectDelta
INFO: Completed parentDeltaQuery for Entity: books
May 10, 2013 5:13:18 PM org.apache.solr.handler.dataimport.DocBuilder doDelta
INFO: Delta Import completed successfully
May 10, 2013 5:13:18 PM org.apache.solr.handler.dataimport.DocBuilder finish
INFO: Import completed successfully
May 10, 2013 5:13:18 PM org.apache.solr.update.DirectUpdateHandler2 commit
INFO: start commit{flags=0,_version_=0,optimize=false,openSearcher=true,waitSearcher=true,expungeDeletes=false,softCommi
t=false}
May 10, 2013 5:13:18 PM org.apache.solr.core.SolrDeletionPolicy onCommit
INFO: SolrDeletionPolicy.onCommit: commits:num=2
like image 292
Jayesh Bhoyar Avatar asked Dec 21 '22 05:12

Jayesh Bhoyar


2 Answers

Changing following values in the data-config.xml has solved the problem

${dih.last_index_time} instead ${dataimporter.last_index_time}

${dih.delta.id} instead ${dataimporter.delta.id} .

I am using SOLR 4.0

like image 175
Jayesh Bhoyar Avatar answered Jan 09 '23 17:01

Jayesh Bhoyar


while calling delta import pass clean parameter = "false" this would help you.

eg: domainname:8983/solr/dataimport?command=delta-import&clean=false'

like image 20
user1730849 Avatar answered Jan 09 '23 16:01

user1730849