Solr Mongo/DocDB Delta Import Query is not working

怎甘沉沦 提交于 2020-04-07 08:22:53

问题


I am trying to import data from Document DB to solr-5.4.1. Full import is executing properly but delta import is not working. When I execute delta import nothing happens

Here is the current delta configuration

deltaQuery="{'lastUpdatedDate':{$exists:true},'lastUpdatedDate':{$gt: Date('${dih.last_index_time}')}}"
            deltaImportQuery="{'_id':'${dih.delta._id}'}"> 

whole db-data-config.xml

<dataConfig>
   <propertyWriter dateFormat="yyyy-MM-dd'T'HH:mm:ss.SSSXXX" type="SimplePropertiesWriter" filename="dataimport.properties"/>

   <document name="tvTitleSearch">
        <entity name="tvTitleSearch"
            processor="MongoEntityProcessor"
            query=""
            collection="tvTitleSearch" 
            datasource="MyMongo"
            transformer="MongoMapperTransformer"
            deltaQuery="{'lastUpdatedDate':{$exists:true},'lastUpdatedDate':{$gt: Date('${dih.last_index_time}')}}"
            deltaImportQuery="{'_id':'${dih.delta._id}'}"> 

                       <field name="id" column="_id" indexed="true" type="uuid" stored="true" mongoField="_id"/>
                      <field column="lastUpdatedDate" sourceColName="lastUpdatedDate" dateTimeFormat="yyyy-MM-dd'T'HH:mm:ss.SSSXXX" locale="en"/>

         </entity>
    </document>

</dataConfig>

sample from managed-schema file

<field type="date" name="modifiedDate"  indexed="true" stored="true"/>
<field type="date" name="lastUpdatedDate"  indexed="true" stored="true"/>

the value stored in DocumentDB:

lastUpdatedDate:2019-11-24T11:43:46.045+00:00

I tried to follow the date-time format as stored in DocumentDB, but still, it did not work, also, I tried suggestions from other similar question asked here but no luck. I tried below snippet in delta query

{lastUpdatedDate : {$gt: ISODate('${dih.last_index_time}')}} , but I got JSON Prasing Excpetion

but got below Exception

java.lang.RuntimeException: org.apache.solr.handler.dataimport.DataImportHandlerException: com.mongodb.util.JSONParseException: 
{'lastUpdatedDate':{$exists:true},'lastUpdatedDate':{$gt: ISODate('2019-11-20T13:14:30.576-08:00')}}

I tried following configuration too

deltaQuery="{'lastUpdatedDate':{$exists:true},'lastUpdatedDate':{$gt: 
{$date:'${dih.last_index_time}'}}}"

could someone please help me or provide any suggestions to trigger delta query


回答1:


The correct way to use the deltaQuery is

deltaQuery="{'lastUpdatedDate':{$exists:true},'lastUpdatedDate':{$gt: {$date:'2020-03-13T08:44:06.959Z'}}}"

as you can see here

However, the SOLR will use ${dih.last_index_time} that is by default formated as 2020-03-13 08:44:06. You'll need to change the format by adding something like the following setting inside your <dateConfig> element.

<propertyWriter dateFormat="yyyy-MM-dd'T'HH:mm:ss.SSSXXX" type="SimplePropertiesWriter" filename="my_dih.properties" locale="en-US"  />


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

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