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. 石头的Xcode学习列表

    http://www.cnblogs.com/JangoJing/tag/xcode/

  2. java 对同一个文件进行读写操作

    同一个文件是不可以进行同时的读写的,因为我们写入文件会覆盖原文件的,如果这样,对于同一文件来来说,文件发生覆盖,无法进行下次读取 当然,对于两个不同的文件,可以一边读一边写的操作 题目:一个文本中存储 ...

  3. Neural Network Programming - Deep Learning with PyTorch with deeplizard.

    PyTorch Prerequisites - Syllabus for Neural Network Programming Series PyTorch先决条件 - 神经网络编程系列教学大纲 每个 ...

  4. 作为程序员你不知道中国互联网300强你就OUT了!

    很多程序员们工作一段时间之后,都想跳槽到综合实力更强的公司以获取高薪资或者接触到前沿的技术,但是哪些行业值得我们投入大量的时间,哪些公司属于我们行业中的佼佼者呢, 那么小编给您分析下2018年中国互联 ...

  5. JAVA 对接腾讯地图,经纬度转换

    package com.lvjing.util; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.spr ...

  6. gggg

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  7. 项目启动失败,异常代码(StandardEngine[Catalina].StandardHost[localhost].StandardContext[/credit]]) ,dataSource 也报错

    问题:tomcat 项目启动失败(有多个springboot项目)! 28-Apr-2019 12:01:12.162 严重 [localhost-startStop-1] org.apache.ca ...

  8. .Net中World转PDF

    using System;using System.Collections.Generic;using System.Linq;using System.Web;using Aspose.Words; ...

  9. UML第二次作业:类在类图中的表示

    类在类图中的表示 一.概览 1.plant UML语法学习小结 2.班级学生管理系统中的 —— “学生” 类的属性.方法 3.类图脚本程序 4.类图示例 二.类图语法学习小结 1.类之间的关系 通过某 ...

  10. Jdbc来操作事物 完成模拟银行的转账业务

    创建JDBC工具类 package cn.aa4_2.JDBCUtils; import java.io.FileReader; import java.io.IOException; import ...