1.把Mysql的Jar包  例如:mysql-connector-java-5.1.8-bin.jar  或其他版本

  放到D:\apache-tomcat-7.0.57\webapps\solr\WEB-INF\lib下

2.然后在tomcat-solr\collection1\conf下新建一个配置文件:data-config.xml,然后在本目录下编辑配置文件:solrconfig.xml

  找到很多个requestHandler节点,在最下面增加:

    <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.10.2文件夹下的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="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/数据库名"
user="root" password="000000"/>
<document>
<entity name="sysDictionary" pk="ID" query="SELECT
'SSR_DICTIONARY' AS type,
CONCAT('SSR_DICTIONARY_',DIC_ID) AS indexId,
DIC_ID AS dicId,
DIC_NAME AS dicName,
DIC_VALUE AS dicValue,
DIC_GROUP AS dicGroup,
DIC_TYPE AS dicType,
DIC_ORDER AS dicOrder,
DIC_STATUS AS dicStatus,
DIC_PARENT_ID AS dicParentId
FROM SYS_DICTIONARY"/>
<entity name="appPerson" pk="ID" query="SELECT
'SSR_DICTIONARY' AS type,
CONCAT('SSR_APPPERSON_',P_ID) AS indexId,
P_ID AS pkid,
P_NAME AS pname,
P_MOBILE AS pmobile,
P_TYPE AS ptype,
P_CREATETIME AS pcreatetime,
P_NOTE AS pnote,
P_STATUS AS pstatus,
P_ORG AS porg,
DIC_GROUP AS dicGroup
FROM APP_PERSON"/>
</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="string" 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="text_ik" indexed="true" stored="true"/>
<field name="pstatus" type="int" indexed="true" stored="true"/>
<field name="porg" type="string" indexed="true" stored="true"/> <!-- SYSDICTIONARY FIELD -->
<field name="dicId" type="string" indexed="true" stored="true"/>
<field name="dicName" type="string" indexed="true" stored="true"/>
<field name="dicValue" type="text_ik" indexed="true" stored="true"/>
<field name="dicGroup" type="string" indexed="true" stored="true"/>
<field name="dicType" type="string" indexed="true" stored="true"/>
<field name="dicOrder" type="int" indexed="false" stored="true"/>
<field name="dicStatus" type="string" indexed="true" stored="true"/>
<field name="dicParentId" type="string" indexed="true" stored="true"/>

这样配置就算是完成了

Solr4.7.0连接MySQL的更多相关文章

  1. VB6.0连接MySQL数据库

    VB6.0连接MySQL数据库

  2. django2.0+连接mysql数据库迁移时候报错

    django2.0+连接mysql数据库迁移时候报错 情况一 错误信息 django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 ...

  3. vc6.0连接mysql数据库

    一.MySQL的安装 Mysql的安装去官网下载就可以...最新的是5.7版本.. 二.VC6.0的设置 (1)打开VC6.中选0 工具栏Tools菜单下的Options选项,在Directories ...

  4. VC++6.0连接MySQL数据库(MySQL API)

    一.MySQL的安装   Mysql的安装去官网下载就可以...最新的是5.7版本..二.VC6.0的设置(1)打开VC6.中选0 工具栏Tools菜单下的Options选项,在Directories ...

  5. asp.net core2.0 连接mysql和mssql

    转自:https://www.jianshu.com/p/15a557ac43d9 1.连接mysql 第一步,新建asp.net core项目   新建项目 本例程作简单演示两种数据库的连接,为简便 ...

  6. Solr4.7.0连接Oracle

    1.把Oracle的Jar包  例如:ojdbc14.jar  或其他版本 放到D:\apache-tomcat-7.0.57\webapps\solr\WEB-INF\lib下 2.然后在tomca ...

  7. Solr4.7.0连接PostgreSQL

    1.把PostgreSQL的Jar包  例如:postgresql-9.1-901-1.jdbc4.jar  或其他版本 放到D:\apache-tomcat-7.0.57\webapps\solr\ ...

  8. DotNetCore跨平台~EFCore2.0连接Mysql的烦恼-已解决

    回到目录 对于传统的nuget包,我们习惯上用官方或者大型组织的,因为它们比较考靠谱,但就在前两天.net core2.0发布后,我把efcore也升级到2.0了,mysql.EfCore也升级到支持 ...

  9. Java spring boot 2.0连接mysql异常:The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone

    解决办法:application.yml提示信息表明数据库驱动com.mysql.jdbc.Driver'已经被弃用了.应当使用新的驱动com.mysql.cj.jdbc.Driver' com.my ...

随机推荐

  1. LimeSDR 无线信号重放攻击和逆向分析

    原文链接:https://mp.weixin.qq.com/s/TBYKZR3n3ADo4oDkaDUeIA

  2. <input > -- radio

    radio 单选按钮的使用.(注意:两个radio的name属性是相同的,才能表现为互斥) </head> <body> <p>这是input标签的用法</p ...

  3. TowSum

  4. 通过JQuery的$.ajax()把 json 数据 post 给 PHP

    通过JQuery的$.ajax()把 json 数据 post 给 PHP时的几种情况: 无法在PHP中通过$_POST 以及 $_REQUEST 获取json数据,即 $json = $_POST[ ...

  5. Altium Designer 10如何导出SMT加工信息和BOM元件清单

    要委托工厂进行SMT加工,需要向工厂提供表贴元器件的位置信息(Pick Place),这些信息可以由csv保存下来. 步骤如下: 一.设定坐标原点,一般设为板子左下角,在Keepout划线的顶点处. ...

  6. celery使用rabbitmq报错[Errno 104] Connection reset by peer.

    写好celery任务文件,使用celery -A app worker --loglevel=info启动时,报告如下错误: [2019-01-29 01:19:26,680: ERROR/MainP ...

  7. [LeetCode&Python] Problem 27. Remove Element

    Given an array nums and a value val, remove all instances of that value in-placeand return the new l ...

  8. Vue.js devtool插件安装后无法使用的解决办法【最简单有效的解决方法】

    在开发vue相关的项目时,使用vue devtools工具是一件极其有趣的事,你所有的操作都马上给你实时反馈. 然而有时候安装好的工具,在chrome中不显示. 在网上找过多次,一直没有找到有效解决方 ...

  9. Fiddler 抓包的基本介绍

    一.什么是Fiddler? Fiddler是一种常见的抓包分析软件,我们可以使用它对HTTP请求进行分析,并模拟对应的HTTP请求. 二.Fiddler抓包实现的原理 Fiddler就相当于某二手车直 ...

  10. UEditor之实现配置简单的图片上传示例 转

    http://blog.csdn.net/huangwenyi1010/article/details/51637427 + http://blog.csdn.net/cr135810/article ...