Solr DIH delta-import with compound primary keys?

╄→尐↘猪︶ㄣ 提交于 2019-12-03 14:40:25
Rye
query="SELECT key1 || key2 as id, ...other fields FROM table"

deltaImportQuery="SELECT key1 || key2 as id, ... other fields
                  FROM table
                  where key1 = '${dataimporter.delta.key1}'
                  and key2 = '${dataimporter.delta.key2}'"

deltaQuery="SELECT key1 || key2 as id, key1, key2
            FROM table
            WHERE lastUpdated > '${dataimporter.last_index_time}'"

Assuming key1 and key2 are text. The single quotes around ${dataimporter.delta.key2} wouldn't be needed if key2 is numeric for example.

Set your deltaQuery to "select 1" which will trigger the deltaImportQuery then just write your deltaImportQuery with the '${dataimporter.last_index_time}' in the where clause

so deltaQuery="select 1" deltaImportQuery="select * from a_table where lastUpdated > '${dataimporter.last_index_time}'"

There are two queries for deltaImport. First one(deltaQuery) is for determining what to index. For example, in it we can define what ID we need to index. The other one is for determining data from this ids. Look at my example, hope, it`ll help you:

<entity name="address" pk="address_id" query="SELECT * FROM address a" deltaImportQuery="SELECT * FROM address a where a.address_id > ${dataimporter.delta.id}"
            deltaQuery="select address_id as id from address where address_id=101010">

Important part of deltaImportQuery is ${dataimporter.delta.id}. This is how we set our id from deltaQuery to deltaImportQuery.

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