如果希望同时对多个表进行全文检索,那我们该如何处理呢?利用DIH导入数据并建立索引时。schema.xml中配置了uniqueKey为id

<uniqueKey>id</uniqueKey>

  如果多表主键都为id的话索引会被覆盖

    <!--deltaImportQuery和deltaQuery为增量导入时使用。-->
<entity name="case"
pk="id"
query="SELECT id,title, summary, 'case' as type FROM case"
deltaImportQuery="SELECT id, title, summary, 'case' as type from case WHERE id='${dih.delta.id}'"
deltaQuery="SELECT id, title, summary, 'case' as type FROM case WHERE create_time > '${dih.last_index_time}'"
>
<!--field用于配置schema.xml中field和数据库字段的对应关系。column:数据库中字段名称,name:schema.xml中配置的名称-->
<field column="id" name="id"/>
<field column="title" name="title"/>
<field column="summary" name="summary"/>
</entity> <!--deltaImportQuery和deltaQuery为增量导入时使用。-->
<entity name="casetest"
pk="id"
query="SELECT id,title, summary, 'case_test' as type FROM casetest"
deltaImportQuery="SELECT id, title, summary, 'case_test' as type from casetest WHERE id='${dih.delta.id}'"
deltaQuery="SELECT id, title, summary, 'case_test' as type FROM casetest WHERE create_time > '${dih.last_index_time}'"
>
<!--field用于配置schema.xml中field和数据库字段的对应关系。column:数据库中字段名称,name:schema.xml中配置的名称-->
<field column="id" name="id"/>
<field column="title" name="title"/>
<field column="summary" name="summary"/>
<field column="type" name="type"/>
</entity>

  由于id是唯一键,如果id重复索引会被覆盖掉。此时可以加个简易的标识,以便构造不同表的uniqueKey

  修改后配置文件

    <!--deltaImportQuery和deltaQuery为增量导入时使用。-->
<entity name="case"
pk="id"
query="SELECT concat('case_Type_', id) as id,title, summary, 'case' as type FROM case"
deltaImportQuery="SELECT concat('case_Type_', id) as id, title, summary, 'case' as type from case WHERE id='${dih.delta.id}'"
deltaQuery="SELECT concat('case_Type_', id) as id, title, summary, 'case' as type FROM case WHERE create_time > '${dih.last_index_time}'"
>
<!--field用于配置schema.xml中field和数据库字段的对应关系。column:数据库中字段名称,name:schema.xml中配置的名称-->
<field column="id" name="id"/>
<field column="title" name="title"/>
<field column="summary" name="summary"/>
</entity> <!--deltaImportQuery和deltaQuery为增量导入时使用。-->
<entity name="casetest"
pk="id"
query="SELECT concat('case_test_Type_', id) as id,title, summary, 'case_test' as type FROM casetest"
deltaImportQuery="SELECT concat('case_test_Type_', id) as id, title, summary, 'case_test' as type from casetest WHERE id='${dih.delta.id}'"
deltaQuery="SELECT concat('case_test_Type_', id) as id, title, summary, 'case_test' as type FROM casetest WHERE create_time > '${dih.last_index_time}'"
>
<!--field用于配置schema.xml中field和数据库字段的对应关系。column:数据库中字段名称,name:schema.xml中配置的名称-->
<field column="id" name="id"/>
<field column="title" name="title"/>
<field column="summary" name="summary"/>
<field column="type" name="type"/>
</entity>

多表利用DIH批量导入数据并建立索引注意事项的更多相关文章

  1. 项目总结04:SQL批量导入数据:将具有多表关联的Excel数据,通过sql语句脚本的形式,导入到数据库

    将具有多表关联的Excel数据,通过sql语句脚本的形式,导入到数据库 写在前面:本文用的语言是java:数据库是MySql: 需求:在实际项目中,经常会被客户要求,做批量导入数据:一般的简单的单表数 ...

  2. 批量导入数据表(oracle)

    批量导入数据表(oracle) 1.登陆plsql 2.找到菜单栏 工具>>导入数据>>新增图标(会提示选择*.csv文件) 选择如上图所示 3.选择数据并导入 4.下图为执行 ...

  3. csv文件批量导入数据到sqlite。

    csv文件批量导入数据到sqlite. 代码: f = web.input(bs_switch = {})  # bs_switch 为from表单file字段的namedata =[i.split( ...

  4. 批量导入数据到mssql数据库的

    概述 批量导入数据到数据库中,我们有好几种方式. 从一个数据表里生成数据脚本,到另一个数据库里执行脚本 从EXCEL里导入数据 上面两种方式,导入的数据都会生成大量的日志.如果批量导入5W条数据到数据 ...

  5. java使用POI实现Excel批量导入数据

    1.准备工作 1.1 创建模板表头与数据库表字段一一对应,示例如下 1.2将模板放入项目中,如下图所示: 2.前端页面 2.1 使用超链接提供模板下载地址 <html lang="zh ...

  6. 使用python向Redis批量导入数据

    1.使用pipeline进行批量导入数据.包含先使用rpush插入数据,然后使用expire改动过期时间 class Redis_Handler(Handler): def connect(self) ...

  7. Cassandra使用pycassa批量导入数据

    本周接手了一个Cassandra系统的维护工作,有一项是需要将应用方的数据导入我们维护的Cassandra集群,并且为应用方提供HTTP的方式访问服务.这是我第一次接触KV系统,原来只是走马观花似的看 ...

  8. Redis批量导入数据的方法

    有时候,我们需要给redis库中插入大量的数据,如做性能测试前的准备数据.遇到这种情况时,偶尔可能也会懵逼一下,这里就给大家介绍一个批量导入数据的方法. 先准备一个redis protocol的文件( ...

  9. asp.net线程批量导入数据时通过ajax获取执行状态

    最近因为工作中遇到一个需求,需要做了一个批量导入功能,但长时间运行没个反馈状态,很容易让人看了心急,产生各种臆想!为了解决心里障碍,写了这么个功能. 通过线程执行导入,并把正在执行的状态存入sessi ...

随机推荐

  1. zabbix_agent安装(Centos+Ubuntu)

      Centos安装 安装依赖包    yum -y install mysql-devel libcurl-devel net-snmp-devel 添加用户 groupadd zabbix use ...

  2. 【poj1201】 Intervals

    http://poj.org/problem?id=1201 (题目链接) 题意 给出n个区间${[ai,bi]}$,要求选出尽可能少的数,使得每个区间i中至少存在${c[i]}$个数. Soluti ...

  3. 【bzoj1486】 HNOI2009—最小圈

    http://www.lydsy.com/JudgeOnline/problem.php?id=1486 (题目链接) 题意 给出一张有向图,规定一个数值u表示图中一个环的权值/环中节点个数.求最小的 ...

  4. [IOS UIalert模版]

    1.alertview创建 UIAlertView *alert; alert = [[UIAlertView alloc] initWithTitle:@"提示" message ...

  5. 取出list的数组元素

    java中将list中的一维数组中的元素取出需要2步.第一步:获取list的迭代器,将数组从迭代器中遍历取出:第二部:对取出的数组进行遍历,取出数组中存储的元素.java的list集合中只能存储引用型 ...

  6. C++ 中的名称冲突之 "y1"

    已经是第二次遇到这个问题了: #include <bits/stdc++.h> using namespace std; ); ][N][][N]; int x1, x2, y1, y2; ...

  7. PHP中soap的使用例子

    PHP 使用soap有两种方式. 一.用wsdl文件 服务器端. <?phpclass service{ public function HelloWorld() { return " ...

  8. Bootstrap教程:[4]栅格系统详解

    http://jingyan.baidu.com/article/6f2f55a1852aa1b5b83e6c5a.html 们都知道bootstrap3.0使用了四种栅格选项来形成栅格系统,这四种选 ...

  9. Linux的学习路线图

    一.学习Linux的基本要求1. 掌握至少50个以上的常用命令. 2. 熟悉Gnome/KDE等X-windows桌面环境操作 . 3. 掌握.tgz..rpm等软件包的常用安装方法 4. 学习添加外 ...

  10. 静态内部类和Lazy<T>优雅实现单例

    public class Singleton { private Singleton() { } public static Singleton GetInstance() { return Conc ...