文件搜索的详细信息
搜索选项
可以在
seafevents.conf
中设置以下选项来控制文件搜索的行为。修改后需要重启
seafile
和
seahub
才能生效。
[INDEX FILES]
## must be "true" to enable search
enabled = true
## config your host and port
es_host = ****
es_port = 9200
## The interval the search index is updated. Can be s(seconds), m(minutes), h(hours), d(days)
interval=10m
## this is for improving the search speed
highlight = fvh
## If true, indexes the contents of office/pdf files while updating search index
## Note: If you change this option from "false" to "true", then you need to clear the search index and update the index again.
index_office_pdf=false
## From 9.0.7 pro, Seafile supports connecting to Elasticsearch through username and password, you need to configure username and password for the Elasticsearch server
username = elastic # username to connect to Elasticsearch
password = elastic_password # password to connect to Elasticsearch
## From 9.0.7 pro, Seafile supports connecting to elasticsearch via HTTPS, you need to configure HTTPS for the Elasticsearch server
scheme = https # The default is http. If the Elasticsearch server is not configured with HTTPS, the scheme and cafile do not need to be configured
cafile = path/to/cert.pem # The certificate path for user authentication. If the Elasticsearch server does not enable certificate authentication, do not need to be configured
## From version 11.0.5 Pro, you can custom ElasticSearch index names for distinct instances when intergrating multiple Seafile servers to a single ElasticSearch Server.
repo_status_index_name = your-repo-status-index-name # default is `repo_head`
repo_files_index_name = your-repo-files-index-name # default is `repofiles`
启用 Office/PDF 文件的全文搜索
为了节省系统资源,默认情况下未启用全文搜索。如果需要启用,请按以下步骤操作:
首先,您必须在
seafevents.conf
中将
index_office_pdf
选项的值设置为
true
然后重新启动seafile服务。
docker exec -it seafile bash
cd seafile-server-latest
./seafile.sh restart
你需要删除现有的搜索索引并重建它。
./pro/pro.py search --clear
./pro/pro.py search --update
常见问题
1.通过 HTTPS 访问 AWS Elasticsearch 服务
-
根据 AWS 文档创建 Elasticsearch 服务。
-
配置 seafevents.conf :
[INDEX FILES]
enabled = true
interval = 10m
index_office_pdf=true
es_host = your domain endpoint(for example, https://search-my-domain.us-east-1.es.amazonaws.com)
es_port = 443
scheme = https
username = master user
password = password
highlight = fvh
repo_status_index_name = your-repo-status-index-name # default is `repo_head`
repo_files_index_name = your-repo-files-index-name # default is `repofiles`
注意:
Python 的第三方包
elasticsearch
版本不能高于
7.14.0
,否则无法访问 AWS Elasticsearch 服务:
2.如果出现问题,请重建索引
您可以通过执行以下命令重建搜索索引:
docker exec -it seafile bash
cd seafile-server-latest
./pro/pro.py search --clear
./pro/pro.py search --update
如果这样不能解决问题,可以尝试以下步骤:
-
停止 Seafile 服务
-
删除旧的搜索索引 rm -rf pro-data/search
-
重启 Seafile 服务
-
稍等片刻,然后执行 ./pro/pro.py search --update
3.当搜索关键字时,没有返回结果
搜索索引默认每10分钟更新一次,所以在执行第一次搜索更新之前,无论你搜索什么都没有结果。
为了能立即搜索:
-
确保您已经启动 Seafile Server
-
手动更新搜索索引:
docker exec -it seafile bash
cd seafile-server-latest
./pro/pro.py search --update
4.无法搜索加密文件
这是因为服务器无法对加密文件进行索引,因为它们被加密了。
5.增加用于搜索的Java进程堆大小
搜索功能基于Elasticsearch服务,这是一个Java进程。要增加Java堆内存大小,可以通过修改jvm配置文件来修改Elasticsearch使用的内存大小空间。例如,修改为2G内存空间。修改
seafile-server-latest/pro/elasticsearch/config/jvm.options
文件的以下配置项:
-Xms2g # 最小使用内存空间
-Xmx2g # 最大使用内存空间
### 建议将以上两个配置项的值设置为一样大小。
重启seafile服务使上述修改生效:
./seafile.sh restart
./seahub.sh restart