zoukankan      html  css  js  c++  java
  • 多表利用DIH批量导入数据并建立索引注意事项

      如果希望同时对多个表进行全文检索,那我们该如何处理呢?利用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>
  • 相关阅读:
    快速幂模板
    部分有关素数的题
    POJ 3624 Charm Bracelet (01背包)
    51Nod 1085 背包问题 (01背包)
    POJ 1789 Truck History (Kruskal 最小生成树)
    HDU 1996 汉诺塔VI
    HDU 2511 汉诺塔X
    HDU 2175 汉诺塔IX (递推)
    HDU 2077 汉诺塔IV (递推)
    HDU 2064 汉诺塔III (递推)
  • 原文地址:https://www.cnblogs.com/rwxwsblog/p/5053320.html
Copyright © 2011-2022 走看看