繁体   English   中英

Solr 4.0增量导入3个表联接

[英]Solr 4.0 Delta-import 3 tables join

我在Ubuntu上使用Solr 4.0 DIH(JDBC连接器)。 我正在尝试使以下MySQL JOIN查询与Delta-import上的Solr一起使用:

select c.*,u.*,g.* from user u inner join group g on u.bus_grp_id = g.dt_grp_id inner join customer c on c.id = g.dt_id

这里的c,u,g分别是表customerusergroup的别名。

以下是用于完全和增量导入的data-config.xml文件:

<entity name="cust" pk="id" query="select c.*,u.*,g.* from user u inner join group g on u.bus_grp_id = g.dt_grp_id inner join customer c on c.id = g.dt_id"
                deltaImportQuery="select c.*,u.*,g.* from user u inner join group g on u.bus_grp_id = g.dt_grp_id inner join customer c on c.id = g.dt_id where c.id='${dih.delta.c.id}'"
                deltaQuery="select id from customer where last_modified &gt; '${dih.last_index_time}'">

                <entity name="grp" pk="dt_id"
                    query="select * from group where dt_id='${cust.c.id}'"
                    deltaQuery="select dt_id from group where last_modified > '${dih.last_index_time}'"
                    parentDeltaQuery="select id from customer where id=${grp.dt_id}" >

                <entity name="usr" pk="bus_grp_id"
                query="select * from user"
                deltaQuery="select bus_grp_id from user where last_modified > '${dih.last_index_time}'"
                parentDeltaQuery="select dt_grp_id from group where dt_grp_id=${usr.bus_grp_id}" >

</entity>
</entity>
</entity>

full-import是可以的,但Delta-import无法正常工作(增量导入后没有任何结果)。 自从我尝试进行这项工作以来已经过去了将近一个月,但未能成功。

有什么帮助吗? 请!

如果查询在您的主要实体元素即

select c.*,u.*,g.* from user u 
inner join group g on u.bus_grp_id = g.dt_grp_id 
inner join customer c on c.id = g.dt_id

为您提供了在Solr中建立索引所需的所有字段,我认为您不需要其他两个子实体。 另外我猜您的deltaImportQuery中有一个错字。 您应该使用dih.delta.id而不是dih.delta.c.id

我想如果您仅保留这一点,它应该可以正常工作:

<entity 
   name="cust" 
   pk="id" 
   query="select c.*,u.*,g.* from user u 
            inner join group g on u.bus_grp_id = g.dt_grp_id 
            inner join customer c on c.id = g.dt_id"
   deltaImportQuery="select c.*,u.*,g.* from user u 
            inner join group g on u.bus_grp_id = g.dt_grp_id 
            inner join customer c on c.id = g.dt_id 
              where c.id='${dih.delta.id}'"
   deltaQuery="select id from customer 
                where last_modified &gt; '${dih.last_index_time}'" />

完全导入后,立即检查文件dataimport.properties。 完全导入完成后,请确保customer表中的某些文档的last_modified大于在dataimport.properties中找到的时间,以便增量有一些数据可以运行。 然后尝试增量导入,看看这些文档是否重新编制了索引。 您可以通过查看http://HOST:PORT/solr/CORE/dataimport找出有多少与增量导入建立索引的索引

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM