当前位置:Gxlcms > 数据库问题 > Solr4.7.0连接Oracle

Solr4.7.0连接Oracle

时间:2021-07-01 10:21:17 帮助过:1人阅读

requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler"> <lst name="defaults"> <str name="config">data-config.xml</str> </lst> </requestHandler> 或      <requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">   <lst name="defaults">   <str name="config">D:\apache-tomcat-7.0.57\webapps\solr\solr_home\collection1\conf\data-config.xml</str>   </lst>   </requestHandler>

3.将初次下载的solr-4.7.0文件夹下的dist, contrib文件夹复制到TomCat根目录下:

  技术分享

 

4.然后再次修改刚才编辑过的solrconfig.xml增加两个文件夹的配置并修改一些参数:

  大约在75行默认有8个路径,但是路径不一定全对,顺着这个配置的路径去找文件夹,根据查找的层数修改这个路径配置,另增加一个新的配置,全文如下:(具体配置还要根据实际情况而定)

技术分享
  <lib dir="D:\apache-tomcat\contrib\extraction\lib" regex=".*\.jar" />

  <lib dir="D:\apache-tomcat\dist\" regex="solr-cell-\d.*\.jar" />

  <lib dir="D:\apache-tomcat\contrib\clustering\lib\" regex=".*\.jar" />

  <lib dir="D:\apache-tomcat\dist\" regex="solr-clustering-\d.*\.jar" />

  <lib dir="D:\apache-tomcat\contrib\langid\lib\" regex=".*\.jar" />

  <lib dir="D:\apache-tomcat\dist\" regex="solr-langid-\d.*\.jar" />

  <lib dir="D:\apache-tomcat\contrib\velocity\lib" regex=".*\.jar" />

  <lib dir="D:\apache-tomcat\dist\" regex="solr-velocity-\d.*\.jar" />

  <lib dir="D:\apache-tomcat\dist\" regex="solr-dataimporthandler-\d.*\.jar" />
技术分享

5. 将dist文件夹下的

  技术分享

  复制到webapps\solr\WEB-INF\lib下。

6.编辑data-config.xml,例如

<!-- db导入solr配置文件 -->
<dataConfig>
    <dataSource driver="oracle.jdbc.driver.OracleDriver"
                url="jdbc:oracle:thin:@IP:1521:数据库名"
                user="user" password="pw"/>
    <document>
        <entity name="appPerson" pk="ID" query="SELECT
            ‘GDWX_APPPERSON‘ AS type,
            ‘GDWX:APPPERSON‘||&quot;PKID&quot; AS indexId,
            &quot;PKID&quot; AS pkid,
            &quot;P_NAME&quot; AS pname,
            &quot;P_MOBILE&quot; AS pmobile,
            &quot;P_TYPE&quot; AS ptype,
            &quot;P_CREATETIME&quot; AS pcreatetime,
            &quot;P_NOTE&quot; AS pnote,
            &quot;P_STATUS&quot; AS pstatus,
            &quot;P_ORG&quot; AS porg
            FROM &quot;APP_PERSON&quot;"/>
    </document>
</dataConfig>

  query是获取全部数据的SQL(solr从sql中获取那些数据),多列

  还可以配置

  deltaImportQuery是获取增量数据时使用的SQL(数据库新增数据追加到solr的数据),多列  (提示:最后索引时间与数据库字段(创建时间比较))   可以试着配置一下

7.编辑schema.xml文件  例如:

   <field name="indexId" type="string" indexed="true" stored="true" required="true" multiValued="false"/>
   <field name="type" type="string" indexed="true" stored="true" required="true" multiValued="false"/>
   <field name="indexTime" type="tdate" default="NOW/SECOND"/>

   <!-- APPPERSON FIELD -->
   <field name="pkid" type="long" indexed="true" stored="true"/>
   <field name="pname" type="string" indexed="true" stored="true"/>
   <field name="pmobile" type="string" indexed="true" stored="true"/>
   <field name="ptype" type="int" indexed="true" stored="true"/>
   <field name="pcreatetime" type="tdate" indexed="true" stored="true"/>
   <field name="pnote" type="string" indexed="false" stored="true"/>
   <field name="pstatus" type="int" indexed="true" stored="true"/>
   <field name="porg" type="string" indexed="true" stored="true"/>

  这样配置就算是完成了

Solr4.7.0连接Oracle

标签:

人气教程排行