简体   繁体   English

Solr增量导入不起作用

[英]Solr delta import does not work

I am using solr 4.2. 我正在使用Solr 4.2。 Note that full import works but somehow delta import doesn't. 请注意,完全导入有效,但增量导入不起作用。 Delta import does not give any error but never fetches any changes. 增量导入不会产生任何错误,但永远不会获取任何更改。 Here's the data config file. 这是数据配置文件。

<dataConfig> 
<dataSource type="JdbcDataSource" 
                   driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" 
                   url="jdbc:sqlserver:testsql;databaseName=test" 
                   user="dba" 
                   password="dba"/> 


  <script>
    <![CDATA[
    function metadataTransformer (row) {
        var attributeName = row.get("attribute_name");
        var attributeValue = row.get("attribute_value");
        row.put(attributeName, attributeValue);

        return row;
    }
    ]]>
  </script>

<document name="PRODUCTS">

<entity name="product" query="select distinct  p.product_id as id from products p
                              inner join products_meta pm on p.product_id = pm.product_id
                              inner join meta m on pm.meta_id = m.meta_id
                              where m.meta_type_id = 11 order by id desc" 

deltaImportQuery="select distinct  p.product_id as id from products p
                              inner join products_meta pm on p.product_id = pm.product_id
                              inner join meta m on pm.meta_id = m.meta_id
                              where m.meta_type_id = 11 and p.product_id='${dih.delta.product_id}'"

deltaQuery= "select distinct  product_id as id from products 
                              where updtime > '${dih.last_index_time}'">

<field column="id" name="id"/> 

<entity name="attribute" query="select attribute_name,attribute_value from solr_import
                                where id =${product.id}" transformer= "script:metadataTransformer">

</entity>
</entity>

</document> 
</dataConfig>

Here's what I have tried without any luck. 这是我没有运气的尝试。

changing p.product_id='${dih.delta.product_id} to p.product_id='${dih.delta.id} and other way also. 将p.product_id ='$ {dih.delta.product_id}更改为p.product_id ='$ {dih.delta.id}以及其他方式。 changing where updtime > '${dih.last_index_time}'" to where updtime > '${dih.last_index_time}'" 将updtime>'$ {dih.last_index_time}'“更改为updtime>'$ {dih.last_index_time}'

Please help. 请帮忙。

This is fixed. 这是固定的。 The issue was solr box was on UTC timezone. 问题是solr box位于UTC时区。 Once I converted that to ET timezone, delta import started working fine. 将其转换为ET时区后,增量导入即可开始正常工作。 Hope this helps someone else. 希望这对其他人有帮助。

If you don't want to use ${dih.last_index_time} (server's time config problem), you can try mysql query like: 如果您不想使用$ {dih.last_index_time}(服务器的时间配置问题),则可以尝试使用mysql查询,例如:

deltaImportQuery="SELECT * FROM table_name where id='${dataimporter.delta.id}'"
deltaQuery="select id from table_name where update_time  > SUBTIME( NOW( ) , '0:15:0' )

I used with crontab and worked fine! 我与crontab一起使用并且工作正常!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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