文件搜索详细配置

文件搜索的详细信息
搜索选项
可以在 seafevents.conf 中设置以下选项来控制文件搜索的行为。修改后需要重启 seafile 和 seahub 才能生效。
[INDEX FILES]
##mustbe"true"toenablesearch
enabled=true

##configyourhostandport
es_host=****
es_port=9200

##Theintervalthesearchindexisupdated.Canbes(seconds),m(minutes),h(hours),d(days)
interval=10m

##thisisforimprovingthesearchspeed
highlight=fvh

##Iftrue,indexesthecontentsofoffice/pdffileswhileupdatingsearchindex
##Note:Ifyouchangethisoptionfrom"false"to"true",thenyouneedtoclearthesearchindexandupdatetheindexagain.
index_office_pdf=false

##From9.0.7pro,SeafilesupportsconnectingtoElasticsearchthroughusernameandpassword,youneedtoconfigureusernameandpasswordfortheElasticsearchserver
username=elastic#usernametoconnecttoElasticsearch
password=elastic_password#passwordtoconnecttoElasticsearch

##From9.0.7pro,SeafilesupportsconnectingtoelasticsearchviaHTTPS,youneedtoconfigureHTTPSfortheElasticsearchserver
scheme=https#Thedefaultishttp.IftheElasticsearchserverisnotconfiguredwithHTTPS,theschemeandcafiledonotneedtobeconfigured
cafile=path/to/cert.pem#Thecertificatepathforuserauthentication.IftheElasticsearchserverdoesnotenablecertificateauthentication,donotneedtobeconfigured

##Fromversion11.0.5Pro,youcancustomElasticSearchindexnamesfordistinctinstanceswhenintergratingmultipleSeafileserverstoasingleElasticSearchServer.
repo_status_index_name=your-repo-status-index-name#defaultis`repo_head`
repo_files_index_name=your-repo-files-index-name#defaultis`repofiles`
启用 Office/PDF 文件的全文搜索
为了节省系统资源,默认情况下未启用全文搜索。如果需要启用,请按以下步骤操作:
首先,您必须在 seafevents.conf 中将 index_office_pdf 选项的值设置为 true
然后重新启动seafile服务。
dockerexec-itseafilebash
cdseafile-server-latest
./seafile.shrestart
你需要删除现有的搜索索引并重建它。
./pro/pro.pysearch--clear
./pro/pro.pysearch--update
常见问题
1.通过 HTTPS 访问 AWS Elasticsearch 服务
  • 根据 AWS 文档创建 Elasticsearch 服务。
  • 配置 seafevents.conf:
[INDEXFILES]
enabled=true
interval=10m
index_office_pdf=true
es_host=yourdomainendpoint(forexample,https://search-my-domain.us-east-1.es.amazonaws.com)
es_port=443
scheme=https
username=masteruser
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.如果出现问题,请重建索引
您可以通过执行以下命令重建搜索索引:
dockerexec-itseafilebash
cdseafile-server-latest
./pro/pro.pysearch--clear
./pro/pro.pysearch--update
如果这样不能解决问题,可以尝试以下步骤:
  1. 停止 Seafile 服务
  2. 删除旧的搜索索引 rm -rf pro-data/search
  3. 重启 Seafile 服务
  4. 稍等片刻,然后执行 ./pro/pro.py search --update
3.当搜索关键字时,没有返回结果
搜索索引默认每10分钟更新一次,所以在执行第一次搜索更新之前,无论你搜索什么都没有结果。
为了能立即搜索:
  • 确保您已经启动 Seafile Server
  • 手动更新搜索索引:
dockerexec-itseafilebash
cdseafile-server-latest
./pro/pro.pysearch--update
4.无法搜索加密文件
这是因为服务器无法对加密文件进行索引,因为它们被加密了。
5.增加用于搜索的Java进程堆大小
搜索功能基于Elasticsearch服务,这是一个Java进程。要增加Java堆内存大小,可以通过修改jvm配置文件来修改Elasticsearch使用的内存大小空间。例如,修改为2G内存空间。修改seafile-server-latest/pro/elasticsearch/config/jvm.options文件的以下配置项:
-Xms2g # 最小使用内存空间
-Xmx2g # 最大使用内存空间
### 建议将以上两个配置项的值设置为一样大小。
重启seafile服务使上述修改生效:
./seafile.shrestart
./seahub.shrestart