Solr7.1---数据库导入并建立中文分词器
这里只是告诉你如何导入,生产环境不要这样部署你的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---数据库导入并建立中文分词器的更多相关文章
- Solr7.2.1环境搭建和配置ik中文分词器
solr7.2.1环境搭建和配置ik中文分词器 安装环境:Jdk 1.8. windows 10 安装包准备: solr 各种版本集合下载:http://archive.apache.org/dist ...
- solr 7+tomcat 8 + mysql实现solr 7基本使用(安装、集成中文分词器、定时同步数据库数据以及项目集成)
基本说明 Solr是一个开源项目,基于Lucene的搜索服务器,一般用于高级的搜索功能: solr还支持各种插件(如中文分词器等),便于做多样化功能的集成: 提供页面操作,查看日志和配置信息,功能全面 ...
- 真分布式SolrCloud+Zookeeper+tomcat搭建、索引Mysql数据库、IK中文分词器配置以及web项目中solr的应用(1)
版权声明:本文为博主原创文章,转载请注明本文地址.http://www.cnblogs.com/o0Iris0o/p/5813856.html 内容介绍: 真分布式SolrCloud+Zookeepe ...
- solr7.2安装实例,中文分词器
一.安装实例 1.创建实例目录 [root@node004]# mkdir -p /usr/local/solr/home/jonychen 2.复制实例相关配置文件 [root@node004]# ...
- Solr7.3.0入门教程,部署Solr到Tomcat,配置Solr中文分词器
solr 基本介绍 Apache Solr (读音: SOLer) 是一个开源的搜索服务器.Solr 使用 Java 语言开发,主要基于 HTTP 和 Apache Lucene 实现.Apache ...
- Lucene全文检索_分词_复杂搜索_中文分词器
1 Lucene简介 Lucene是apache下的一个开源的全文检索引擎工具包. 1.1 全文检索(Full-text Search) 1.1.1 定义 全文检索就是先分词创建索引,再执行搜索的过 ...
- 11大Java开源中文分词器的使用方法和分词效果对比,当前几个主要的Lucene中文分词器的比较
本文的目标有两个: 1.学会使用11大Java开源中文分词器 2.对比分析11大Java开源中文分词器的分词效果 本文给出了11大Java开源中文分词的使用方法以及分词结果对比代码,至于效果哪个好,那 ...
- Elasticsearch系列---使用中文分词器
前言 前面的案例使用standard.english分词器,是英文原生的分词器,对中文分词支持不太好.中文作为全球最优美.最复杂的语言,目前中文分词器较多,ik-analyzer.结巴中文分词.THU ...
- ElasticSearch7.3学习(十五)----中文分词器(IK Analyzer)及自定义词库
1. 中文分词器 1.1 默认分词器 先来看看ElasticSearch中默认的standard 分词器,对英文比较友好,但是对于中文来说就是按照字符拆分,不是那么友好. GET /_analyze ...
随机推荐
- Apache和Tomcat整合(一个Apache 不同域名处理多个不同业务)
一.简介 在项目中,几乎任何一个项目都包括静态资源和动态请求两大部分.特别对于门户网站这样的项目,静态内容资源会更多,我们使用一般的 Tomcat 部署时,Tomcat 对静态资源的处理能力比较慢,至 ...
- AJAX中使用post,get接收发送数据的区别
如何发起请求 xhr.send(); 备注: 如果是get方式,send()命令中不用写任何参数 传递的数据可以写在url中,服务器用$_GEET["参数名"]接收 如果是post ...
- 一个简易内存池(C++)
做这个内存池主要是为了完成一道面试题,题目在代码中. 代码 #include <iostream> #include<string> #include <list> ...
- 关于C++中vector和set使用sort方法进行排序
C++中vector和set都是非常方便的容器, sort方法是algorithm头文件里的一个标准函数,能进行高效的排序,默认是按元素从小到大排序 将sort方法用到vector和set中能实现多种 ...
- JAVAscript学习笔记 js计时器与倒计时 第六节 (原创) 参考js使用表
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- windows下 sbulime text 安装less2css踩的几个坑
sublime 就不介绍了,less2css 是一个安装在sublime上的插件,可以让你书写less后自动生成css文件,而且还可以提示less的语法错误. 搜了一下相关的教程,很多都写的不全,按照 ...
- Kotlin实现LeetCode算法题之String to Integer (atoi)
题目String to Integer (atoi)(难度Medium) 大意是找出给定字串开头部分的整型数值,忽略开头的空格,注意符号,对超出Integer的数做取边界值处理. 方案1 class ...
- 学python+django去北京找工作,靠谱吗?
有些朋友说,自己的学习能力还可以.倾向于python加框架,如django,python本来就会一些.不太了解北京公司的情况,想知道现学的python+django在北京找到工作有多少可能性. 要想知 ...
- 五:Token问题和使用详解
什么是Token? Token可以理解为令牌,服务端通过验证Token,来判断你是否有这个操作的权限.Token的重要特性是有效性,一般Token只在一定时间范围内有效.下图是登录模块的一个流程图,展 ...
- C# 程序集安装与卸载
下面我们来实现程序集的安装,代码如下: /// <summary>/// 程序集安装与卸载/// </summary>/// <param name="asse ...