solr数据导入和添加中文分词器

首先修改solrConfig.xml文件

备份_default文件夹

solr数据导入和添加中文分词器_第1张图片

修改solrconfig.xml

solr数据导入和添加中文分词器_第2张图片

加入如下内容

 

官方示例:

  
    /path/to/my/DIHconfigfile.xml
  

 

效果:

solr数据导入和添加中文分词器_第3张图片

 

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

 

复制代码


    
    
        
            
            
            
        
    

复制代码

 

 

 我的数据库

solr数据导入和添加中文分词器_第4张图片

 

 

复制jar

找到这个:

solr数据导入和添加中文分词器_第5张图片

连同mysql驱动包一起复制到

solr数据导入和添加中文分词器_第6张图片

 

找到自带的中文分词器

solr数据导入和添加中文分词器_第7张图片

复制到webapp的lib目录

solr数据导入和添加中文分词器_第8张图片

 

 修改managed-shchema

solr数据导入和添加中文分词器_第9张图片

在最后加入如下中文配置

复制代码

    
    
      
        
      
      
        
      
    

复制代码

 solr数据导入和添加中文分词器_第10张图片

 

下面以cloud模式启动

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

复制代码

D:\>cd solr-7.1.0

D:\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 run in your local cluster? (spec
ify 1-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 port for 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 port 8983 using 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 to 30 to see Solr running on port 8983

Starting up Solr on port 7574 using 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 port 8983. Happy searching!
Waiting up to 30 to see Solr running on port 7574
INFO  - 2017-11-04 12:35:02.823; org.apache.solr.client.solrj.impl.ZkClientClust
erStateProvider; Cluster at localhost:9983 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 7574. Happy searching!
bless【输入名称并回车】
How many shards would you like to split bless into? [2]
【回车】
How many replicas per shard would you like to create? [2]
【回车】
Please choose a configuration for the 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 3 secs 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 3000


SolrCloud example running, please visit: http://localhost:8983/solr


D:\solr-7.1.0>

复制代码

 

 下面访问

选择bless

solr数据导入和添加中文分词器_第11张图片

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

bless_id

solr数据导入和添加中文分词器_第12张图片

bless_content

solr数据导入和添加中文分词器_第13张图片

 

bless_time

solr数据导入和添加中文分词器_第14张图片

 

 

点击DataImport

solr数据导入和添加中文分词器_第15张图片

要注意勾选Auto-Refresh Status

 

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

 solr数据导入和添加中文分词器_第16张图片

下面看一下中文分词

solr数据导入和添加中文分词器_第17张图片

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

solr数据导入和添加中文分词器_第18张图片

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

solr数据导入和添加中文分词器_第19张图片

 试试搜索【心】

solr数据导入和添加中文分词器_第20张图片

你可能感兴趣的:(技术)