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. mysql 存储 2

    mysql> create database db1; mysql> use db1; mysql> create table PLAYERS as select * from TE ...

  2. Linux 驱动——Button驱动5(atomic)原子量

    button_drv.c驱动文件: #include <linux/module.h>#include <linux/kernel.h>#include <linux/f ...

  3. Linux 驱动——Button驱动3(poll机制)

    button_drv.c驱动文件: #include <linux/module.h>#include <linux/kernel.h>#include <linux/f ...

  4. 路径R

    定义文件路径时前面加个r 例如 firstfolder = r"C:\Users\1261\Desktop\" 不对其中的符号进行转义

  5. Js/Session和Cookies的区别

    1.cookies数据存放在客户的浏览器上面,session放在服务器上面.2.cookies不安全,别人可以分析浏览器的数据进行cookies的欺骗,考虑到安全性,应该使用cookie3.sessi ...

  6. python 异步发送邮件 aiosmtplib

    aiosmtplib is an asynchronous SMTP client for use with asyncio.文档地址 与 smtplib的用法大体相同 有几个地方需要注意下: 加密S ...

  7. js常用随手记

    1. 判断是否是空对象 let myObject={} Object.keys(myObject).length 2. void 0 代替 undefined undefined 不是保留字,在局部作 ...

  8. JSF相关介绍

    About JavaServer Faces technology simplifies building user interfaces for JavaServer applications. D ...

  9. Java基于opencv实现图像数字识别(四)—图像降噪

    Java基于opencv实现图像数字识别(四)-图像降噪 我们每一步的工作都是基于前一步的,我们先把我们前面的几个函数封装成一个工具类,以后我们所有的函数都基于这个工具类 这个工具类呢,就一个成员变量 ...

  10. vue+axios跨域解决方法

    通过这种方法也可以解决跨域的问题. 使用http-proxy-middleware 代理解决(项目使用vue-cli脚手架搭建) 例如请求的url:“http://f.apiplus.cn/bj11x ...