简体   繁体   English

Solr Delta导入查询不起作用

[英]Solr Delta Import Query is not working

I am trying to import data from Mongodb to Solr6.0. 我正在尝试将数据从Mongodb导入到Solr6.0。 Full import is executing properly but delta import is not working. 完全导入正在正确执行,但增量导入无法正常工作。 When I execute delta import I get below result. 当我执行增量导入时,我得到以下结果。

Requests: 0 , Fetched: 0 , Skipped: 0 , Processed: 0 请求:0,已提取:0,已跳过:0,已处理:0

My data config file queries are as below 我的数据配置文件查询如下

query=""

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

the whole data-config.xml 整个data-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>

I tried with hardcoded values, but it still not worked like below 我尝试使用硬编码的值,但仍然无法像下面那样工作

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

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

And then I tried doing the below thing, but still no success 然后我尝试做以下事情,但仍然没有成功

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

Anybody, Please if you can. 任何人,请可以。

can you replace {'_id':'${dataimporter.delta.id}'} to {'_id':'${dataimporter.delta. 是否可以将{'_id':'$ {dataimporter.delta.id}'}替换为{'_id':'$ {dataimporter.delta。 _id }'} in deltaImportQuery. _id }'}在deltaImportQuery中。

deltaImportQuery : (Only used in delta-import) .There is a namespace ${dih.delta. deltaImportQuery:(仅在增量导入中使用)。存在命名空间$ {dih.delta。 column-name } which can be used in this query. 可以在此查询中使用的列名 }。 eg: select * from tbl where id=${dih.delta.id} Solr1.4 例如:从tbl中选择*,其中id = $ {dih.delta.id} Solr1.4

as above line mentioned that we can only use column name in delta namespace. 如上所述,我们只能在增量名称空间中使用列名称。

Same problem also faced during delta import from mysql in question Solr delta import Query exception 从有问题的mysql进行delta导入期间也遇到相同的问题Solr delta import查询异常

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

你能试一下吗

deltaQuery as db.getCollection('customer').find({'jDate':{$gt:**ISODate(**'${dih.last_index_time}'**)**}},{'_id' :1});

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

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