solr对跨服务器表联合查询的配置

目前我们有两个库,不在同一个服务器上,如:A服务器上库有个account表,B服务器上有个两个库:其实就是把一个大数据表拆分成两个库,比如 follow1有个表A B和C,follow2有个C D和E表,其实都是存放相同的数据,这六个表的数据差不多有1000W,现在建索引我这边需要一个多小时,data-config.xml配置如下

<dataConfig>

   <dataSource type="JdbcDataSource" name="ds-1" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://ip1:5901/relationship_1" user="****"    password="*****" batchSize="-1"/>    <dataSource type="JdbcDataSource" name="ds-2" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://ip1:5902/relationship_2" user="****"    password="******" batchSize="-1"/>    <dataSource type="JdbcDataSource" name="ds-3" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://ip2:3306/v506" user="****"    password="******" batchSize="-1"/>

 <document name="follow_log">    <entity dataSource="ds-1" name="following1" pk="logId" query="select cast(CONCAT(accountId,targetAccount) as SIGNED INTEGER) logId, accountId,targetAccount,followFlag,friendF lag,followTime,friendTime,friendly,blockFlag,blockReason,blockTime,joinFlag from ((select * from relationship_following_1 ) union all (select * from relationship_following_3 ) u nion all (select * from relationship_following_5 )) as f" deltaImportQuery="select cast(CONCAT(accountId,targetAccount) as SIGNED INTEGER) logId, accountId,targetAccount,followF lag,friendFlag,followTime,friendTime,friendly,blockFlag,blockReason,blockTime,joinFlag from ((select * from relationship_following_1 where cast(CONCAT(accountId,targetAccount) a s SIGNED INTEGER) = '${dih.delta.logId}') union all (select * from relationship_following_3 where cast(CONCAT(accountId,targetAccount) as SIGNED INTEGER) = '${dih.delta.logId}')  union all (select * from relationship_following_5 where cast(CONCAT(accountId,targetAccount) as SIGNED INTEGER) = '${dih.delta.logId}')) as f" deltaQuery="select f.logId from ( (select cast(CONCAT(accountId,targetAccount) as SIGNED INTEGER) logId from relationship_following_1 where followTime >= '${dih.last_index_time}' or friendTime >= '${dih.last_ind ex_time}') union all (select cast(CONCAT(accountId,targetAccount) as SIGNED INTEGER) logId from relationship_following_3 where followTime >= '${dih.last_index_time}' or friendTi me >= '${dih.last_index_time}') union all (select cast(CONCAT(accountId,targetAccount) as SIGNED INTEGER) logId from relationship_following_5 where followTime >= '${dih.last_ind ex_time}' or friendTime >= '${dih.last_index_time}')) as f">       <field column="logId" name="logId"/>       <field column="accountId" name="accountId"/>       <field column="targetAccount" name="targetAccount"/>       <field column="followFlag" name="followFlag"/>       <field column="friendFlag" name="friendFlag"/>       <field column="followTime" name="followTime"/>       <field column="friendTime" name="friendTime"/>       <field column="friendly" name="friendly"/>       <field column="blockFlag" name="blockFlag"/>       <field column="blockReason" name="blockReason"/>       <field column="blockTime" name="blockTime"/>       <field column="joinFlag" name="joinFlag"/>           <entity dataSource="ds-3" name="account" query="select name,photoPath,l99NO,accountType,online from account where accountId = '${following1.targetAccount}'">                   <field column="name" name="name"/>                   <field column="photoPath" name="photoPath"/>                   <field column="l99NO" name="l99NO"/>                   <field column="accountType" name="accountType"/>                   <field column="online" name="online"/>           </entity>    </entity>    <entity dataSource="ds-2" name="following2" pk="logId" query="select cast(CONCAT(accountId,targetAccount) as SIGNED INTEGER) logId, accountId,targetAccount,followFlag,friendF lag,followTime,friendTime,friendly,blockFlag,blockReason,blockTime,joinFlag from ((select * from relationship_following_2 ) union all (select * from relationship_following_4 ) u nion all (select * from relationship_following_6 )) as f" deltaImportQuery="select cast(CONCAT(accountId,targetAccount) as SIGNED INTEGER) logId, accountId,targetAccount,followF lag,friendFlag,followTime,friendTime,friendly,blockFlag,blockReason,blockTime,joinFlag from ((select * from relationship_following_2 where cast(CONCAT(accountId,targetAccount) a s SIGNED INTEGER) = '${dih.delta.logId}') union all (select * from relationship_following_4 where cast(CONCAT(accountId,targetAccount) as SIGNED INTEGER) = '${dih.delta.logId}')  union all (select * from relationship_following_6 where cast(CONCAT(accountId,targetAccount) as SIGNED INTEGER) = '${dih.delta.logId}')) as f" deltaQuery="select f.logId from ( (select cast(CONCAT(accountId,targetAccount) as SIGNED INTEGER) logId from relationship_following_2 where followTime >= '${dih.last_index_time}' or friendTime >= '${dih.last_ind ex_time}') union all (select cast(CONCAT(accountId,targetAccount) as SIGNED INTEGER) logId from relationship_following_4 where followTime >= '${dih.last_index_time}' or friendTi me >= '${dih.last_index_time}') union all (select cast(CONCAT(accountId,targetAccount) as SIGNED INTEGER) logId from relationship_following_6 where followTime >= '${dih.last_ind ex_time}' or friendTime >= '${dih.last_index_time}')) as f">       <field column="logId" name="logId"/>       <field column="accountId" name="accountId"/>       <field column="targetAccount" name="targetAccount"/>       <field column="followFlag" name="followFlag"/>       <field column="friendFlag" name="friendFlag"/>       <field column="followTime" name="followTime"/>

<field column="friendTime" name="friendTime"/>       <field column="friendly" name="friendly"/>       <field column="blockFlag" name="blockFlag"/>       <field column="blockReason" name="blockReason"/>       <field column="blockTime" name="blockTime"/>       <field column="joinFlag" name="joinFlag"/>           <entity dataSource="ds-3" name="account" query="select name,photoPath,l99NO,accountType,online from account where accountId = '${following2.targetAccount}'">                   <field column="name" name="name"/>                   <field column="photoPath" name="photoPath"/>                   <field column="l99NO" name="l99NO"/>                   <field column="accountType" name="accountType"/>                   <field column="online" name="online"/>           </entity>     </entity>    </document> </dataConfig>


学习这个没多久,不知道有没有更好的办法来实现

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值