一、安装 full text 相关的几个 app 插件,可以直接在nextcloud中设置→应用中搜索安装
二、安装Elasticsearch(yum安装参考下面两个文档)
https://blog.youkuaiyun.com/smxalong/article/details/103568418
https://blog.youkuaiyun.com/smxalong/article/details/103568146
三、安装ES插件和ik分词
参考文档:https://github.com/nextcloud/fulltextsearch/wiki/Basic-Installation
# ingest-attachment
/usr/share/elasticsearch/bin/elasticsearch-plugin install ingest-attachment
#安装IK分词
/usr/share/elasticsearch/bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.5.0/elasticsearch-analysis-ik-7.5.0.zip
如果要删除重新安装
/usr/share/elasticsearch/bin/elasticsearch-plugin remove ingest-attachment
/usr/share/elasticsearch/bin/elasticsearch-plugin remove analysis-ik
四、在NextCloud设置管理页面配置全文搜索设置(确保full text相关插件都已经启用)
五、初始化索引,确保ES服务器正常启动
[root@bogon ~]# curl -X GET localhost:9200
{
"name" : "bogon",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "ZReKMkitQ5CgpjTsz6HMIQ",
"version" : {
"number" : "7.4.2",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "2f90bbf7b93631e52bafb59b3b049cb44ec25e96",
"build_date" : "2019-10-28T20:40:44.881551Z",
"build_snapshot" : false,
"lucene_version" : "8.2.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
进入nextcloud目录:
cd /www/wwwroot/test.wxlcloud.com/nextcloud
初始化索引(需要安装 php-readline 和 php-pcntl 两个扩展):
sudo -u www php ./occ fulltextsearch:index
六、创建并启动持续索引服务
由于全文索引需要不停的进行(因为有新的文件进来),做成centos服务
在 /etc/systemd/system/ 目录下创建 nextcloud-fulltext-elasticsearch-worker.service 文件,文件内容如下(用到MySql服务):
[Unit]
Description=Elasticsearch Worker for Nextcloud Fulltext Search
After=network.target mysql.service
Requires=mysql.service
[Service]
User=www
Group=www
WorkingDirectory=/www/wwwroot/test.wxlcloud.com/nextcloud
ExecStart=/usr/bin/php /www/wwwroot/test.wxlcloud.com/nextcloud/occ fulltextsearch:live -q
ExecStop=/usr/bin/php /www/wwwroot/test.wxlcloud.com/nextcloud/occ fulltextsearch:stop
Nice=19
Restart=always
[Install]
WantedBy=multi-user.target
开机启动:
systemctl enable nextcloud-fulltext-elasticsearch-worker.service
systemctl start nextcloud-fulltext-elasticsearch-worker.service