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 ...
随机推荐
- AngularJS学习篇(十四)
AngularJS 事件 ng-click 指令 ng-click 指令定义了 AngularJS 点击事件. <!DOCTYPE html> <html> <head& ...
- Fiddler系列教程3:使用Fiddler录制Jmeter性能测试脚本
今天继续给大家带来Fiddler工具的教程3:使用Fiddler录制Jmter性能测试脚本. 我们知道Jmeter本身可以录制脚本,也可以通过BadBoy,BlazeMeter等工具进行录制,其实Fi ...
- ueditor精简插件和减少初次加载文件的方法
ueditor初次使用的时候加载的文件大小大概有1MB还要多,这个页面的打开速度相对来说是很慢很慢的. 其实通常我们并不需要ueditor的全部功能,通过chromedev工具发现初次加载的时候就调用 ...
- RE: Javascript分页处理
背景: 调用PHP后端给的接口,以实现分页的功能.由于我是没造轮子的能力,所以翻了不少技术博客,经过整合才算完成整个分页功能.从一番查阅中,不难看出大概分为两种不同的分页: 一种是纯前端的,就是在一次 ...
- C#图片水印代码整理
这一段公司有个项目,客户要求上传的图片要带上自定义的水印.以前也经常和朋友讨论C#图片水印方面的问题,但是从来没有实际操作过.所以,借这次项目的机会也研究了一下C#图片水印的功能!本人参考的是disc ...
- C#.Net调用VB.Net中的MY
用过VB.NET的人应该只要MY有多强大了吧,是不是很想在C#中也能调用呢? 当然是可以的,.net作为微软的跨语言的平台,必须是能实现的,不然微软就自己打自己嘴巴了~ 回到正题上: 1.在程序中加上 ...
- mongoose返回值无法修改
mongoose 查询方法 find 例:db.collections.find(query,function(err,doc) { 如果var res = doc[0] 是{name:'feife ...
- python调用c代码2
1.生成动态链接库 [root@typhoeus79 c]# more head.c #include <stdio.h> #include <stdlib.h> typede ...
- [转]SQL Server为啥使用了这么多内存?
原文地址:http://support.microsoft.com/gp/anxin_techtip6/zh-cn SQL Server为啥使用了这么多内存? SQL Server的用户,常常会发现S ...
- javascript第六章--BOM
① window对象 ② location对象 ③ navigator对象 ④ screen对象 ⑤ history对象