【问题标题】:Solr Delta Import Query is not workingSolr 增量导入查询不起作用
【发布时间】:2019-02-11 23:07:59
【问题描述】:

我正在尝试将数据从 Mongodb 导入 Solr6.0。完全导入正确执行,但增量导入不起作用。当我执行增量导入时,我得到以下结果。

请求: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}'})"

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

我尝试使用硬编码值,但仍然无法像下面那样工作

     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)}"

任何人,如果可以的话,请。

【问题讨论】:

  • @TMBT 请帮帮我。我有你建议的这个新问题。
  • 在您进行完全导入后是否有任何变化?
  • 是的。完全导入后,我在 MongoDB 中添加了一个新文档,然后运行 ​​delta import
  • 只是好奇为什么您的查询=“”(空)。不应该和你做完全导入时的一样吗?
  • @root545 empty 表示获取所有记录。

标签: mongodb solr mongodb-query solr6


【解决方案1】:

您能否将 deltaImportQuery 中的 {'_id':'${dataimporter.delta.id}'} 替换为 {'_id':'${dataimporter.delta._id}'}。

deltaImportQuery :(仅用于 delta-import)。有一个命名空间 ${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

【讨论】:

    【解决方案2】:

    你可以试试

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

    【讨论】:

      猜你喜欢
      • 2020-03-16
      • 2012-08-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-23
      • 1970-01-01
      相关资源
      最近更新 更多