Solr DIH delta-import 带有复合主键?
我的 Solr 数据源是一个 SQL 数据库,其中主键是复合的(即它有两个字段)。
这对于我的主要 DIH 查询
来说很好,我只需连接字段即可成为我的 Solr 主键。然而,从文档中并不清楚我如何编写增量导入查询来支持这一点。
该文档建议我需要两个查询 - 一个查询用于查找已更改行的主键,另一个查询用于实际检索与每个键对应的单个文档。不过,没有示例显示复合键的这一点。
理想情况我根本不想要这两个单独的查询,如果将这两个查询简单地组合起来,那么数据库上的负载就会减少,这样查询
和deltaQuery
是基于 last_changed
进行过滤的 WHERE
子句。
因此,如果我的主要查询
是:
SELECT key1 || key2 as pk FROM table
相关的deltaQuery
(和/或deltaImportQuery
)会是什么样子?
我尝试仅添加 WHERE
子句,但在查询运行后,我收到了有关缺少 deltaImportQuery
的警告,然后收到了空指针异常。
My Solr data source is a SQL database where the primary key is compound (i.e. it's two fields).
This is fine for my main DIH query
, I just concatenate the fields and that becomes my Solr primary key. However it's unclear from the documentation how I'd write a delta-import query to support this.
The documentation suggests I need two queries - one to find the primary key of the changed rows, and another to then actually retrieve the individual documents corresponding to each of those keys. There's no example showing this for compound keys though.
Ideally I don't want those two separate queries at all, it would put less load on the database if those two queries were simply combined such that the only difference between query
and deltaQuery
is the WHERE
clause that filters based on last_changed
.
So, if my main query
is:
SELECT key1 || key2 as pk FROM table
What would the relevant deltaQuery
(and/or deltaImportQuery
) look like?
I tried just adding the WHERE
clause but after the query ran I got a warning about the missing deltaImportQuery
and then a null-pointer exception.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
假设 key1 和 key2 是文本。例如,如果 key2 是数字,则不需要 ${dataimporter.delta.key2} 周围的单引号。
Assuming key1 and key2 are text. The single quotes around ${dataimporter.delta.key2} wouldn't be needed if key2 is numeric for example.
将 deltaQuery 设置为“select 1”,这将触发 deltaImportQuery
然后只需在 where 子句中使用 '${dataimporter.last_index_time}' 编写 deltaImportQuery
即可 deltaQuery="select 1"
deltaImportQuery =“从a_table中选择*,其中lastUpdated>'$ {dataimporter.last_index_time}'”
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}'"
有两个 deltaImport 查询。第一个(deltaQuery)用于确定要索引的内容。例如,我们可以在其中定义我们需要索引什么ID。另一个用于根据该 id 确定数据。看看我的例子,希望它能帮助你:
deltaImportQuery 的重要部分是 ${dataimporter.delta.id}。这就是我们将 id 从 deltaQuery 设置为 deltaImportQuery 的方法。
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:
Important part of deltaImportQuery is ${dataimporter.delta.id}. This is how we set our id from deltaQuery to deltaImportQuery.