使用 SeaSearch 作为搜索引擎 (Pro)

SeaSearch 是一种比   Elasticsearch 更轻量级、更高效的文件索引器,从 Seafile 12 开始支持。
我们 目前仅支持   SeaSearch Server 的基于 Docker 的部署,因此本文档介绍使用 Docker 部署 Seafile 服务器的情况进行配置。
理论 上, 如果您的   Seafile 服务器部署在集群模式下,至少后端节点必须重新启动,但我们仍然建议您配置并重新启动 所有节点 ,以确保集群中的一致性和同步性。
部署 SeaSearch 服务
SeaSearch 服务目前主要通过 docker 部署。我们已将其集成到相关的 docker-compose 文件中。您只需将其下载到与 seafile-server.yml 相同的目录:
            
                
                
#12.0
wget https://manual.seafile.com/12.0/repo/docker/pro/seasearch.yml

#13.0
wget https://manual.seafile.com/13.0/repo/docker/pro/seasearch.yml
修改 .env
我们在 .env 中配置了相关变量。这里要特别注意以下变量信息,这些信息会影响 SeaSearch 的初始化过程。关于 SeaSearch 服务的   .env 变量 。我们使用   /opt/seasearch-data   作为 SeaSearch 的持久目录(管理员信息与 Seafile 13 中默认的 Seafile 管理员相同)
对于苹果的芯片, 由于苹果的芯片(如 M2)不支持   MKL ,因此需要将相关镜像设置为   xxx-nomkl:latest ,例如:
            
                
                
SEASEARCH_IMAGE=seafileltd/seasearch-nomkl:latest
            
                
                
#For 12.0
COMPOSE_FILE='...,seasearch.yml' # ... means other docker-compose files

#SEASEARCH_IMAGE=seafileltd/seasearch-nomkl:0.9-latest # for Apple's Chip
SEASEARCH_IMAGE=seafileltd/seasearch:0.9-latest

SS_DATA_PATH=/opt/seasearch-data
INIT_SS_ADMIN_USER=<admin-username>
INIT_SS_ADMIN_PASSWORD=<admin-password>
            
                
                
#For 13.0
COMPOSE_FILE='...,seasearch.yml' # ... means other docker-compose files

#SEASEARCH_IMAGE=seafileltd/seasearch-nomkl:1.0-latest # for Apple's Chip
SEASEARCH_IMAGE=seafileltd/seasearch:1.0-latest

SS_DATA_PATH=/opt/seasearch-data
INIT_SS_ADMIN_USER=<admin-username>
INIT_SS_ADMIN_PASSWORD=<admin-password>


# from 13.0 ,if you would like to use S3 for saving seasearch data
SS_STORAGE_TYPE=s3
S3_SS_BUCKET=...
S3_KEY_ID=<your-key-id>
S3_SECRET_KEY=<your-secret-key>
S3_USE_V4_SIGNATURE=true
S3_PATH_STYLE_REQUEST=false
S3_AWS_REGION=us-east-1
S3_HOST=
S3_USE_HTTPS=true
S3_SSE_C_KEY=
修改 seafile-server.yml 以禁用   elasticSearch   服务
如果您想使用   SeaSearch   作为搜索引擎,可以删除不再使用的   elasticSearch   服务:删除文件   .env   上的列表变量 COMPOSE_FILE 中的 elasticsearch.yml
修改   seafevents.conf
  1. 通过 base64 代码获取您的授权令牌(seasearch_token),该代码由   .env   中定义的   INIT_SS_ADMIN_USER     INIT_SS_ADMIN_PASSWORD   组成,用于在调用 SeaSearch API 时进行授权:
            
                
                
echo -n 'username:password' | base64

# example output
YWRtaW46YWRtaW5fcGFzc3dvcmQ=
2. 在 seafevents 中添加以下部分,使 seafile 后端服务能够访问 SeaSearch API:
            
                
                
[SEASEARCH]
enabled = true
seasearch_url = http://seasearch:4080
seasearch_token = <your auth token> #generate by step 1
interval = 10m

# if you would like to enable full-text indexing (i.e., search for document content), also set the option below to true (support from 13.0 Pro)
index_office_pdf = true
SeaSearch 服务器部署在使用 Seafile 的不同机器上:
            
                
                
如果您的 SeaSearch 服务器部署在使用 Seafile 的不同机器上,请将 http://seasearch:4080 替换为您的 SeaSearch 服务器的 url ://:
3. 禁用 ElasticSearch,因为您可以在   INDEX FILES   部分中设置   enabled = false
            
                
                
[INDEX FILES]
enabled = false
...
重启Seafile Server
            
                
                
docker compose down
docker compose up -d
启动 SeaSearch 服务后,您可以查看以下日志,了解 SeaSearch 是否正常运行,Seafile 是否调用成功:
  • 通过命令 docker logs -f seafile-seasearch 的容器日志
  • /opt/seasearch-data/log/seafevents.log
首次启动 SeaSearch Server 后, 您可以删除   .env 初始管理员帐户信息(例如   INIT_SS_ADMIN_USER INIT_SS_ADMIN_PASSWORD ),这些信息仅用于 SeaSearch 初始化进度(即首次启动服务 )。但请确保 您已将其记录在其他地方,以防您忘记密码
其他配置
设置标记化语言
默认情况下,SeaSearch 使用专为英语 / 德语 / 法语设计的基于单词的分词器。您可以添加以下配置以使用专为中文设计的分词器。
            
                
                
[SEASEARCH]
enabled = true
...
lang = chinese
如何删除旧的索引重新创建新索引
删除旧索引数据:
            
                
                
rm -rf /opt/seasearch-data/*
创建新的索引数据:
            
                
                
$ cd /opt/seafile/seafile-server-latest
$ ./pro/pro.py search --update