简体   繁体   English

Solr 4.0增量导入3个表联接

[英]Solr 4.0 Delta-import 3 tables join

I am using Solr 4.0 DIH(JDBC connector) on Ubuntu. 我在Ubuntu上使用Solr 4.0 DIH(JDBC连接器)。 I am trying to make the following MySQL JOIN query work with Solr on Delta-import : 我正在尝试使以下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

Here c, u, g are the aliases of the tables customer , user and group respectively. 这里的c,u,g分别是表customerusergroup的别名。

Below is the data-config.xml file for full and delta import: 以下是用于完全和增量导入的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>

The full-import is ok but the Delta-import is not working(I'm getting no results after delta import). full-import是可以的,但Delta-import无法正常工作(增量导入后没有任何结果)。 It's been almost one month since I'm trying to make this work but couldn't. 自从我尝试进行这项工作以来已经过去了将近一个月,但未能成功。

Any help? 有什么帮助吗? please! 请!

If the query in your main entity element ie 如果查询在您的主要实体元素即

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

is giving you all the fields you need to index in Solr, I don't think you need the other two sub-entities. 为您提供了在Solr中建立索引所需的所有字段,我认为您不需要其他两个子实体。 Also I guess there is a typo in your deltaImportQuery. 另外我猜您的deltaImportQuery中有一个错字。 You should use dih.delta.id and not dih.delta.c.id . 您应该使用dih.delta.id而不是dih.delta.c.id

I guess if you keep just this, it should work fine: 我想如果您仅保留这一点,它应该可以正常工作:

<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}'" />

As soon as you do a full import, check the file dataimport.properties. 完全导入后,立即检查文件dataimport.properties。 Once your full import completes, make sure you got some documents in customer table with last_modified greater than the time you find in dataimport.properties so the delta has some data to run on. 完全导入完成后,请确保customer表中的某些文档的last_modified大于在dataimport.properties中找到的时间,以便增量有一些数据可以运行。 Then try delta import and see if those docs get re-indexed. 然后尝试增量导入,看看这些文档是否重新编制了索引。 You can find out how many got indexed with the delta import by looking at http://HOST:PORT/solr/CORE/dataimport 您可以通过查看http://HOST:PORT/solr/CORE/dataimport找出有多少与增量导入建立索引的索引

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

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