簡體   English   中英

Solr增量導入不起作用

[英]Solr delta import does not work

我正在使用Solr 4.2。 請注意,完全導入有效,但增量導入不起作用。 增量導入不會產生任何錯誤,但永遠不會獲取任何更改。 這是數據配置文件。

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

這是我沒有運氣的嘗試。

將p.product_id ='$ {dih.delta.product_id}更改為p.product_id ='$ {dih.delta.id}以及其他方式。 將updtime>'$ {dih.last_index_time}'“更改為updtime>'$ {dih.last_index_time}'

請幫忙。

這是固定的。 問題是solr box位於UTC時區。 將其轉換為ET時區后,增量導入即可開始正常工作。 希望這對其他人有幫助。

如果您不想使用$ {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' )

我與crontab一起使用並且工作正常!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM