Ubuntu 16.04 LTS下安装配置Solr-Mmseg4j

简介: 安装环境:Ubuntu 16.04 LTS; Java JDK 1.8.0目录检查系统环境安装Apache Solr配置solr-mmseg4j1.

安装环境:Ubuntu 16.04 LTS; Java JDK 1.8.0

目录
  1. 检查系统环境
  2. 安装Apache Solr
  3. 配置solr-mmseg4j

1. 检查系统环境

  • 检查java环境
java -version

img_9fec2b23297c9c019ec4d60fcb4e8d59.png

所需java版本是1.8.0
相关链接: Ubuntu 16.04 LTS下安装配置Java环境

  • 系统安装更新
sudo apt-get update

2. 安装Apache Solr

img_5e3167e5903d21119a3ae37e71cb10a9.png

solr-6.5.1.tgz和solr-6.5.1.zip是一样的。这里我们下载的是solr-6.5.1.tgz

img_9c089a74bf23f4d802cb618659218ffd.png
  • 解压文件
tar zxvf solr-6.5.1.tgz
  • 在8080端口启动Solr 服务
cd solr-6.5.1/bin
sudo ./solr start -p 8080 -force

启动成功


img_b6ce23f2247b1407a6a8fad254de68b7.png

3. 配置solr-mmseg4j

  • 上传jar包


    img_a2a9e9055120fc8b7aba71378c73d30f.png
cd ../server/solr-webapp/webapp/WEB-INF/lib

mmseg4j-core-1.10.0.jarmmseg4j-solr-2.3.0.jar两个文件上传到/solr-6.5.1/server/solr-webapp/webapp/WEB-INF/lib路径下

img_ac5c328cb9400a22674d8971f2bdcc3f.png
  • 新建一个core
    在bin目录下执行命令,生成的core0在/solr-6.5.1/server/solr/目录下
sudo ./solr create -c core0 -p 8080 -force
cd ../server/solr/core0
tree
 .
├── conf
│   ├── currency.xml
│   ├── elevate.xml
│   ├── lang
│   │   ├── contractions_ca.txt
│   │   ├── contractions_fr.txt
│   │   ├── contractions_ga.txt
│   │   ├── contractions_it.txt
│   │   ├── hyphenations_ga.txt
│   │   ├── stemdict_nl.txt
│   │   ├── stoptags_ja.txt
│   │   ├── stopwords_ar.txt
│   │   ├── stopwords_bg.txt
│   │   ├── stopwords_ca.txt
│   │   ├── stopwords_cz.txt
│   │   ├── stopwords_da.txt
│   │   ├── stopwords_de.txt
│   │   ├── stopwords_el.txt
│   │   ├── stopwords_en.txt
│   │   ├── stopwords_es.txt
│   │   ├── stopwords_eu.txt
│   │   ├── stopwords_fa.txt
│   │   ├── stopwords_fi.txt
│   │   ├── stopwords_fr.txt
│   │   ├── stopwords_ga.txt
│   │   ├── stopwords_gl.txt
│   │   ├── stopwords_hi.txt
│   │   ├── stopwords_hu.txt
│   │   ├── stopwords_hy.txt
│   │   ├── stopwords_id.txt
│   │   ├── stopwords_it.txt
│   │   ├── stopwords_ja.txt
│   │   ├── stopwords_lv.txt
│   │   ├── stopwords_nl.txt
│   │   ├── stopwords_no.txt
│   │   ├── stopwords_pt.txt
│   │   ├── stopwords_ro.txt
│   │   ├── stopwords_ru.txt
│   │   ├── stopwords_sv.txt
│   │   ├── stopwords_th.txt
│   │   ├── stopwords_tr.txt
│   │   └── userdict_ja.txt
│   ├── managed-schema
│   ├── params.json
│   ├── protwords.txt
│   ├── solrconfig.xml
│   ├── stopwords.txt
│   └── synonyms.txt
├── core.properties
└── data
    ├── index
    │   ├── segments_1
    │   └── write.lock
    ├── snapshot_metadata
    └── tlog

6 directories, 49 files

如图,conf中放的是配置文件,stopwords中放的是停用词

  • /conf/managed-schema中添加如下代码(可以使用vim编辑器直接修改)
<!-- mmseg4j-->
<field name="mmseg4j_complex_name" type="text_mmseg4j_complex" indexed="true" stored="true"/>
<field name="mmseg4j_maxword_name" type="text_mmseg4j_maxword" indexed="true" stored="true"/>
<field name="mmseg4j_simple_name" type="text_mmseg4j_simple" indexed="true" stored="true"/>

<fieldType name="text_mmseg4j_complex" class="solr.TextField" positionIncrementGap="100" >
  <analyzer>
    <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="complex" dicPath="/usr/local/solr-6.5.1/server/solr/my_dic"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
  </analyzer>
</fieldType>
<fieldType name="text_mmseg4j_maxword" class="solr.TextField" positionIncrementGap="100" >
  <analyzer>
    <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="max-word" dicPath="/usr/local/solr-6.5.1/server/solr/my_dic"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
  </analyzer>
</fieldType>
<fieldType name="text_mmseg4j_simple" class="solr.TextField" positionIncrementGap="100" >
  <analyzer>
    <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="simple" dicPath="/usr/local/solr-6.5.1/server/solr/my_dic"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
  </analyzer>
</fieldType>
<!-- mmseg4j-->

其中,dicPath是dic字典文件的存放路径,这里写的是绝对路径。
/usr/local/solr-6.5.1/server/solr路径下新建my_dic文件夹mkdir my_dic
然后就可以把字典文件上传到这个目录了

  • 重启solr
sudo ./solr restart -p 8080 -force

img_901d78848c3d9645266ce48c2c9de119.png

安装成功
img_200c2d853f4f05b6836b23ddac88814e.png

参考链接:
http://lucene.apache.org/solr/quickstart.html
solr 中文分词 mmseg4j 使用例子

目录
相关文章
|
18天前
|
Ubuntu 安全 Linux
Linux(34)Rockchip RK3568 Ubuntu22.04和Debian 10上配置远程桌面工具
Linux(34)Rockchip RK3568 Ubuntu22.04和Debian 10上配置远程桌面工具
65 0
|
3月前
|
Kubernetes Ubuntu 应用服务中间件
在Ubuntu22.04 LTS上搭建Kubernetes集群
在Ubuntu22.04.4上安装Kubernetes v1.28.7,步骤超详细
389 1
在Ubuntu22.04 LTS上搭建Kubernetes集群
|
3月前
|
网络协议 Java 应用服务中间件
Springboot+ubuntu+Let‘s Encrypt配置https
Springboot+ubuntu+Let‘s Encrypt配置https
38 0
|
3月前
|
Ubuntu
百度搜索:蓝易云【Ubuntu开机自启服务systemd.service配置教程】
现在,你的服务将在Ubuntu开机时自动启动,并在之后的启动中持续运行。记得根据你的实际需求修改 `your_service_name.service`文件中的相关信息。
63 2
|
4月前
|
存储 网络协议 Ubuntu
如何在Ubuntu安装配置SVN服务端并实现无公网ip访问内网资料库
如何在Ubuntu安装配置SVN服务端并实现无公网ip访问内网资料库
76 0
|
4月前
|
Ubuntu 安全 网络安全
百度搜索:蓝易云【Ubuntu系统SSH服务端配置】
现在,你已经成功在Ubuntu系统上配置了SSH服务端。这将允许其他计算机通过SSH协议连接到你的Ubuntu系统,并进行远程管理和操作。请注意,远程访问有安全风险,建议在生产环境中采取必要的安全措施来保护系统。
41 3
|
3月前
|
负载均衡 Ubuntu 应用服务中间件
|
13天前
|
Ubuntu 安全 Linux
【专栏】在Ubuntu 22.04 LTS中,管理用户和权限对系统安全至关重要
【4月更文挑战第28天】在Ubuntu 22.04 LTS中,管理用户和权限对系统安全至关重要。使用`adduser`和`deluser`命令可轻松添加和删除用户,而`sudo`命令则允许授权用户执行管理员任务。要授予用户sudo权限,可通过`usermod -aG sudo newuser`将用户加入`sudo`组,或使用`visudo`编辑`/etc/sudoers`文件。撤销权限时,只需移除用户从`sudo`组或编辑`sudoers`文件删除相应配置。了解这些技能能有效保护系统免受未授权访问,确保安全。
|
17天前
|
Ubuntu Linux
Linux(Ubuntu)系统临时IP以及静态IP配置(关闭、启动网卡等操作)
请注意,以上步骤是在临时基础上进行配置的。如果要永久保存静态IP地址,通常还需要修改 `/etc/network/interfaces`文件,以便在系统重启后保持配置。同时,确保备份相关配置文件以防止出现问题。
31 1
|
18天前
|
Ubuntu Linux 测试技术
Linux(32)Rockchip RK3568 Ubuntu22.04上部署 Docker: 详细配置与功能测试(下)
Linux(32)Rockchip RK3568 Ubuntu22.04上部署 Docker: 详细配置与功能测试
49 1