2016-11-30 140 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