Solr Delta Import Query is not working

倖福魔咒の 提交于 2019-12-25 08:04:09

问题


I am trying to import data from Mongodb to 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

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

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


回答1:


can you replace {'_id':'${dataimporter.delta.id}'} to {'_id':'${dataimporter.delta._id}'} in deltaImportQuery.

deltaImportQuery : (Only used in delta-import) .There is a namespace ${dih.delta.column-name} which can be used in this query. e.g: select * from tbl where 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

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




回答2:


Can you try

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


来源:https://stackoverflow.com/questions/40881185/solr-delta-import-query-is-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!