solr mysql 分词_Solr7.1---数据库导入并建立中文分词器

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

首先修改solrConfig.xml文件

备份_default文件夹

cc8ccc621bec213ef4ae1319149226ed.png

修改solrconfig.xml

4e13395e6a17ea9d25606e9de186babe.png

加入如下内容

官方示例:

/path/to/my/DIHconfigfile.xml

效果:

89c0217f5d9e0e5d040dde9f1f586b6f.png

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

我的数据库

70875cecaff1c46d48f7261549776177.png

复制jar

找到这个:

20e30f821dc0812690fb08f96ffc77f4.png

连同mysql驱动包一起复制到

e28a1107dac5707882ccccfd52fcc1ab.png

找到自带的中文分词器

589d19059705919af712997da6ab95ce.png

复制到webapp的lib目录

aeb8d4de889d47ddbc291cf3cf328957.png

修改managed-shchema

ed7da83e74a4d189514fc145007925b7.png

在最后加入如下中文配置

a202e86e5541c5c411f2dcea7a21cc2d.png

下面以cloud模式启动

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

D:\>cd solr-7.1.0D:\solr-7.1.0>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 runin your local cluster?(spec

ify1-4 nodes) [2]:

【回车】

Ok, let's start up 2 Solr nodes for your example SolrCloud cluster.

Please enter the port for node1 [8983]:

【回车】

Please enter the portfor node2 [7574]:

【回车】

Solr home directory D:\solr-7.1.0\example\cloud\node1\solr already exists.

D:\solr-7.1.0\example\cloud\node2 already exists.

Starting up Solr on port8983using command:"D:\solr-7.1.0\bin\solr.cmd" start -cloud -p 8983 -s "D:\solr-7.1.0\example\clou

d\node1\solr"Waiting up to30 to see Solr running on port 8983Starting up Solr on port7574using command:"D:\solr-7.1.0\bin\solr.cmd" start -cloud -p 7574 -s "D:\solr-7.1.0\example\clou

d\node2\solr"-z localhost:9983

Started Solr server on port8983. Happy searching!Waiting up to30 to see Solr running on port 7574INFO- 2017-11-04 12:35:02.823; org.apache.solr.client.solrj.impl.ZkClientClust

erStateProvider; Cluster at localhost:9983ready

Now let's create a new collection for indexing documents in your 2-node cluster.

Please provide a nameforyour new collection: [gettingstarted]

Started Solr server on port7574. Happy searching!bless【输入名称并回车】

How many shards would you like tosplit bless into? [2]

【回车】

How many replicas per shard would you like to create? [2]

【回车】

Please choose a configurationforthe bless collection, available options are:

_default or sample_techproducts_configs [_default]

【回车】

Created collection'bless' with 2 shard(s), 2 replica(s) with config-set 'bless'Enabling auto soft-commits with maxTime 3secs using the Config API

POSTing request to Config API: http://localhost:8983/solr/bless/config

{"set-property":{"updateHandler.autoSoftCommit.maxTime":"3000"}}

Successfully set-property updateHandler.autoSoftCommit.maxTime to 3000SolrCloud example running, please visit: http://localhost:8983/solr

D:\solr-7.1.0>

下面访问

选择bless

465d6092df677569f0c5967ca3693c8b.png

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

bless_id

9fa3418a4bf5377d73bdd8ab8b984749.png

bless_content

5e9dad7c85f117b54980da4d8b598eb8.png

bless_time

fc733ba8dbb62aa493dc75ff80974b95.png

点击DataImport

29ac4f0d6b6e8644f9a6d625c638c8c8.png

要注意勾选Auto-Refresh Status

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

361aefd88bccab6458c1e43d416ee847.png

下面看一下中文分词

1461e3aa440950dc36b7024b499aff76.png

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

e75d1436883cce9170277b3e51146061.png

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

e0b195b3a4f4ae4643742dd385735463.png

试试搜索【心】

58616f7d6f3d5458720d0d6ba007e758.png

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值