delta导入处理程序无法正常工作

时间:2013-05-10 12:02:43

标签: solr dih

我按照提到的步骤进行了@:http://wiki.apache.org/solr/DataImportHandler

我也尝试过stackoverflow的其他解决方案但是它仍然无法正常工作。

问题是: 我每次运行时都配置了Delta-import处理程序;它索引来自DB的所有记录。 我在DB中有30条记录。每次我运行delta导入时,它都会索引所有30条记录。我只希望将那些被更改/删除的内容编入索引。

对此问题的任何快速帮助/指针/解决方案表示赞赏。


数据-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>

我用来执行它的命令是:

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

dataimport.properties文件:

5月10日星期五17:13:18 2013年IST

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

在日志文件中我得到了以下内容:

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

2 个答案:

答案 0 :(得分:9)

更改data-config.xml中的以下值已解决了问题

$ {dih.last_index_time} 而非 $ {dataimporter.last_index_time}

$ {dih.delta.id} 而非 $ {dataimporter.delta.id}

我正在使用 SOLR 4.0

答案 1 :(得分:2)

在调用delta import pass clean parameter =“false”时,这对你有帮助。

例如:domainname:8983 / solr / dataimport?command = delta-import&amp; clean = false'