2016-11-30 155 views
0

我想從Mongodb導入數據到Solr6.0。完全導入正在正確執行,但增量導入不起作用。當我執行增量導入時,我會得到下面的結果。Solr Delta導入查詢不起作用

請求:0,抓取時間:0,跳過:0,加工:0

我的數據配置文件查詢是如下

query="" 

deltaQuery="db.getCollection('customer').find({'jDate':{$gt:'${dih.last_index_time}'}},{'_id' :1});" 
deltaImportQuery="db.getCollection('customer').find({'_id':'${dataimporter.delta.id}'})" 

整個數據-config.xml中

<?xml version="1.0"?> 
<dataConfig> 
<dataSource name="MyMongo" type="MongoDataSource" database="test_db" /> 
<document name="import"> 
<!-- if query="" then it imports everything --> 
    <entity processor="MongoEntityProcessor" 
      query="" 
      deltaQuery="db.getCollection('customer').find({'jDate':{$gt: '${dih.last_index_time}'}},{'_id' :1});" 
      deltaImportQuery="db.getCollection('customer').find({'_id':'${dataimporter.delta.id}'})" 
      collection="customer" 
      datasource="MyMongo" 
      transformer="MongoMapperTransformer" name="sample_entity"> 

       <!-- If mongoField name and the field declared in schema.xml are same than no need to declare below. 
        If not same than you have to refer the mongoField to field in schema.xml 
        (Ex: mongoField="EmpNumber" to name="EmployeeNumber"). -->            

      <field column="_id" name="id"/> 
      <field column="CustID" name="CustID" mongoField="CustID"/>  

      <field column="CustName" name="CustName" mongoField="CustName"/>  
      <field column="jDate" name="jDate" mongoField="jDate"/> 
      <field column="dob" name="dob" mongoField="dob"/>   
     </entity> 
</document> 
</dataConfig> 

我試着用硬編碼值,但它仍然沒有奏效像下面

 query="" 
    deltaQuery="db.getCollection('customer').find({'jDate':{$gt: new Date(1480581295000)}},{'_id' :1});" 

deltaImportQuery="db.getCollection('customer').find({'_id':ObjectId('34234234dfsd34534524234ee')})" 

然後我試着做下面的事情,但仍然沒有成功

query="" 
     deltaQuery="{'jDate':{$gt: new Date(1480581295000)}}" 
     deltaImportQuery="{'_id':ObjectId(34234234dfsd34534524234ee)}" 

任何人,請如果你能。

+0

@TMBT請幫我在this.I具有您所建議的這個新問題。 – Kamini

+0

自從您完全導入之後,您有任何更改嗎? – root545

+0

是的。完全導入後,我在MongoDB中添加了一個新文檔,然後運行delta導入 – Kamini

回答

0

您能否將{'_id':'$ {dataimporter.delta.id}'}替換爲{'_id':'$ {dataimporter.delta。 _id}'} in deltaImportQuery。

deltaImportQuery :(僅在delta導入中使用)。有一個命名空間$ {dih.delta。 column-name}可用於此查詢。例如:select * from tbl where id = $ {dih.delta.id} Solr1.4

如上所述,我們只能在delta命名空間中使用列名。

同樣的問題也從MySQL問題面臨增量導入期間 Solr delta import Query exception

參考:
https://wiki.apache.org/solr/DataImportHandler https://wiki.apache.org/solr/DataImportHandler#Configuration_in_data-config.xml