这里只是告诉你如何导入,生产环境不要这样部署你的solr服务。

首先修改solrConfig.xml文件

备份_default文件夹

修改solrconfig.xml

加入如下内容

官方示例:
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">/path/to/my/DIHconfigfile.xml</str>
</lst>
</requestHandler>

效果:

在conf目录建立一个db-data-config.xml文件

<dataConfig>
<dataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/demo" user="root" password="" />
<document>
<entity name="bless" query="select * from bless"
deltaQuery="select bless_id from bless where bless_time > '${dataimporter.last_index_time}'">
<field column="BLESS_ID" name="blessId" />
<field column="BLESS_CONTENT" name="blessContent" />
<field column="BLESS_TIME" name="blessTime" />
</entity>
</document>
</dataConfig>

我的数据库

复制jar

找到这个:

连同mysql驱动包一起复制到

找到自带的中文分词器

复制到webapp的lib目录

修改managed-shchema

在最后加入如下中文配置

    <!-- ChineseAnalyzer -->
<fieldType name="solr_cnAnalyzer" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="org.apache.lucene.analysis.cn.smart.HMMChineseTokenizerFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="org.apache.lucene.analysis.cn.smart.HMMChineseTokenizerFactory"/>
</analyzer>
</fieldType>

下面以cloud模式启动

整个过程只需要输入 索引集合 的名称,其他都是一路回车。

D:\>cd solr-7.1.

D:\solr-7.1.>bin\solr start -e cloud

Welcome to the SolrCloud example!

This interactive session will help you launch a SolrCloud cluster on your local
workstation.
To begin, how many Solr nodes would you like to run in your local cluster? (spec
ify - nodes) []:
【回车】
Ok, let's start up 2 Solr nodes for your example SolrCloud cluster.
Please enter the port for node1 []:
【回车】
Please enter the port for node2 []:
【回车】
Solr home directory D:\solr-7.1.\example\cloud\node1\solr already exists.
D:\solr-7.1.\example\cloud\node2 already exists. Starting up Solr on port using command:
"D:\solr-7.1.0\bin\solr.cmd" start -cloud -p -s "D:\solr-7.1.0\example\clou
d\node1\solr" Waiting up to to see Solr running on port Starting up Solr on port using command:
"D:\solr-7.1.0\bin\solr.cmd" start -cloud -p -s "D:\solr-7.1.0\example\clou
d\node2\solr" -z localhost:9983 Started Solr server on port . Happy searching!
Waiting up to to see Solr running on port
INFO - -- ::02.823; org.apache.solr.client.solrj.impl.ZkClientClust
erStateProvider; Cluster at localhost: ready Now let's create a new collection for indexing documents in your 2-node cluster. Please provide a name for your new collection: [gettingstarted]
Started Solr server on port . Happy searching!
bless【输入名称并回车】
How many shards would you like to split bless into? []
【回车】
How many replicas per shard would you like to create? []
【回车】
Please choose a configuration for the bless collection, available options are:
_default or sample_techproducts_configs [_default]
【回车】
Created collection 'bless' with shard(s), replica(s) with config-set 'bless' Enabling auto soft-commits with maxTime secs using the Config API POSTing request to Config API: http://localhost:8983/solr/bless/config
{"set-property":{"updateHandler.autoSoftCommit.maxTime":""}}
Successfully set-property updateHandler.autoSoftCommit.maxTime to SolrCloud example running, please visit: http://localhost:8983/solr D:\solr-7.1.>

下面访问

选择bless

然后选择Schema,来配置字段【注意:这里的名字要与数据库中的字段名一模一样!!!】

bless_id

bless_content

bless_time

点击DataImport

要注意勾选Auto-Refresh Status

现在点击Query。可以看到,数据库中的数据都导入了。

下面看一下中文分词

看起来还不错。查询试试看。

发现0条数据,至少也得有一条啊!然而如果我指定默认搜索字段。会发现出来了。

试试搜索【心】

关于数据库的文件,大家如果想要用来测试可以GitHub

Solr7.1---数据库导入并建立中文分词器的更多相关文章

  1. Solr7.2.1环境搭建和配置ik中文分词器

    solr7.2.1环境搭建和配置ik中文分词器 安装环境:Jdk 1.8. windows 10 安装包准备: solr 各种版本集合下载:http://archive.apache.org/dist ...

  2. solr 7+tomcat 8 + mysql实现solr 7基本使用(安装、集成中文分词器、定时同步数据库数据以及项目集成)

    基本说明 Solr是一个开源项目,基于Lucene的搜索服务器,一般用于高级的搜索功能: solr还支持各种插件(如中文分词器等),便于做多样化功能的集成: 提供页面操作,查看日志和配置信息,功能全面 ...

  3. 真分布式SolrCloud+Zookeeper+tomcat搭建、索引Mysql数据库、IK中文分词器配置以及web项目中solr的应用(1)

    版权声明:本文为博主原创文章,转载请注明本文地址.http://www.cnblogs.com/o0Iris0o/p/5813856.html 内容介绍: 真分布式SolrCloud+Zookeepe ...

  4. solr7.2安装实例,中文分词器

    一.安装实例 1.创建实例目录 [root@node004]# mkdir -p /usr/local/solr/home/jonychen 2.复制实例相关配置文件 [root@node004]#  ...

  5. Solr7.3.0入门教程,部署Solr到Tomcat,配置Solr中文分词器

    solr 基本介绍 Apache Solr (读音: SOLer) 是一个开源的搜索服务器.Solr 使用 Java 语言开发,主要基于 HTTP 和 Apache Lucene 实现.Apache ...

  6. Lucene全文检索_分词_复杂搜索_中文分词器

    1 Lucene简介 Lucene是apache下的一个开源的全文检索引擎工具包. 1.1 全文检索(Full-text Search)  1.1.1 定义 全文检索就是先分词创建索引,再执行搜索的过 ...

  7. 11大Java开源中文分词器的使用方法和分词效果对比,当前几个主要的Lucene中文分词器的比较

    本文的目标有两个: 1.学会使用11大Java开源中文分词器 2.对比分析11大Java开源中文分词器的分词效果 本文给出了11大Java开源中文分词的使用方法以及分词结果对比代码,至于效果哪个好,那 ...

  8. Elasticsearch系列---使用中文分词器

    前言 前面的案例使用standard.english分词器,是英文原生的分词器,对中文分词支持不太好.中文作为全球最优美.最复杂的语言,目前中文分词器较多,ik-analyzer.结巴中文分词.THU ...

  9. ElasticSearch7.3学习(十五)----中文分词器(IK Analyzer)及自定义词库

    1. 中文分词器 1.1 默认分词器 先来看看ElasticSearch中默认的standard 分词器,对英文比较友好,但是对于中文来说就是按照字符拆分,不是那么友好. GET /_analyze ...

随机推荐

  1. [译]ASP.NET Core 2.0 布局页面

    问题 如何在ASP.NET Core 2.0项目中共享可见元素.代码块和指令? 答案 新建一个空项目,首先添加GreetingService服务和UserViewModel模型: public int ...

  2. Log4j 2翻译 Garbage-free Steady State Logging(稳定的以不会生成垃圾的状态来记录日志)

    本人菜鸟,在学习Log4j 2 的时候做的一些笔记---对"官方网站"的翻译,部分内容自己也不懂,希望大家指点 Garbage collection pauses are a co ...

  3. 关于C++中vector和set使用sort方法进行排序

    C++中vector和set都是非常方便的容器, sort方法是algorithm头文件里的一个标准函数,能进行高效的排序,默认是按元素从小到大排序 将sort方法用到vector和set中能实现多种 ...

  4. grunt任务自动管理

    Grunt管理工具使用: 一.模块安装 1.在项目的根目录里新建package.json文件,形式如下,指定依赖的库以及版本信息. 2.然后在项目根目录下,执行 npm install ,安装json ...

  5. Problem F: 分数类的类型转换

    Description 封装一个分数类Fract,用来处理分数功能和运算,支持以下操作:   1. 构造:传入两个参数n和m,表示n/m:分数在构造时立即转化成最简分数. 2. show()函数:分数 ...

  6. web前端学习路线和步骤

    H5+全栈工程师  (学习下列技术可以加QQ: 1416 7596 61)第一阶段:初级入门阶段基本功 1.HTML入门 Windows概述.浏览器概述.HTML简介.HTML标签详解.前端开发工具概 ...

  7. Python文件夹备份

    Python文件夹备份 import os,shutil def file_copy(path1,path2): f2 = [filename1 for filename1 in os.listdir ...

  8. 小米/红米导入VCF联系人乱码问题解决

    PS:尽量不要用什么豌豆荚啊.微信啊.QQ啊之类的通讯录备份,那就等于把自己的通讯录免费送给腾讯他们了....还是自己手动的好一些,但是小白用户或者经常丢手机的卖就卖吧,总比联系人都丢了要好~~~ 默 ...

  9. spirngMVC的搭建

    1 springMVC的搭建肯定是需要用到一系列的jar包的,那么第一步就是去spring官网下载对应版本的jar包 可以通过 http://www.cnblogs.com/imentors/p/49 ...

  10. Delphi工程版本号修改工具

    自动修改某目录下符合条件的Delphi工程(dproj)版本号, 支持命令行调用支持通配符忽略文件 -p [Path] 在[Path]路径下查询所有dproj文件(可以为空, 默认路径为程序当前路径) ...