📔

Flarum中文搜索使用Sonic引擎解决方案

Flarum中文搜索使用Sonic引擎解决方案备用文档 来源:https://discuss.flarum.org.cn/d/2797
1\. 配置Sonic config.cfg (目录、配置等以下仅为方便示范,有改动需求自己改即可)
进入root目录(再次重申,目录仅为演示,自己按需调整),新建名为sonic文件夹,新建名为config.cfg文件,填入以下配置:
`[server]

log_level = "error"

[channel]

inet = "0.0.0.0:1491"
tcp_timeout = 30

auth_password = "SecretPassword"

[channel.search]

query_limit_default = 10
query_limit_maximum = 100
query_alternates_try = 4

suggest_limit_default = 5
suggest_limit_maximum = 20

[store]

[store.kv]

path = "/var/lib/sonic/store/kv/"

retain_word_objects = 1000

[store.kv.pool]

inactive_after = 1800

[store.kv.database]

flush_after = 900

compress = true
parallelism = 2
max_files = 100
max_compactions = 1
max_flushes = 1
write_buffer = 16384
write_ahead_log = true

[store.fst]

path = "/var/lib/sonic/store/fst/"

[store.fst.pool]

inactive_after = 300

[store.fst.graph]

consolidate_after = 180

max_size = 2048
max_words = 250000`

2\. 安装Sonic

以docker为例。
先自行搜索docker安装方法,然后守护态run(注意目录位置,你上面没改那这边也不用改):
`docker run -d -p 1491:1491 -v ~/sonic/config.cfg:/etc/sonic.cfg -v ~/sonic/store/:/var/lib/sonic/store/ valeriansaliou/sonic:v1.3.0`

3\. 安装插件

`composer require ganuonglachanh/sonic`

3\. 后台设置,按默认填写就行

4\. 建立索引(安装后只运行这一次就行)

`php flarum sonic:addtoindex`
已知问题: