ralkage/flarum-ext-search
Composer 安装命令:
composer require ralkage/flarum-ext-search
包简介
Meilisearch-backed full-text search for Flarum: typo tolerance, prefix matching, post-content search, highlighted snippets, queued indexing.
README 文档
README
Meilisearch-backed full-text search for Flarum. Drop-in replacement for Flarum's default MySQL LIKE-based search, adding typo tolerance, prefix matching, instant fuzzy matches, per-field weighting (title > content), and proper relevance ranking.
What you get
- Typo tolerance: "wellcom" finds "Welcome", "annoucement" finds "Announcement".
- Searches inside replies: a query that matches only the 14th post in a long thread now surfaces that discussion. Default Flarum search would miss it.
- Highlighted post snippets in the search dropdown: the matching post (not just the first) shows beneath each result.
- Tag-aware visibility: Meilisearch-side filtering against the actor's visible tags. Flarum's normal
whereVisibleTostill gates final results, so nothing leaks. - Live updates: every post create/edit/hide/delete reindexes via a queued job. With Flarum's default
syncdriver it runs inline (no setup); switch to Redis/database for real async.
Requirements
- Flarum
^1.8 - A reachable Meilisearch instance (
^1.0)
Install
composer require ralkage/flarum-ext-search
Enable in Admin → Extensions → Better Search.
Run a Meilisearch instance. Docker is the easiest path:
docker run -d --name meilisearch -p 7700:7700 \ -v meilisearch_data:/meili_data \ -e MEILI_ENV=development \ --restart unless-stopped \ getmeili/meilisearch:v1.11
For production, set MEILI_MASTER_KEY=<long-random-string> and pass it in the admin settings page.
Build the initial index:
php flarum search:reindex
Or click Rebuild index now on the settings page.
Configuration
All settings live on the admin extension page:
| Setting | Default | Purpose |
|---|---|---|
| Host URL | http://127.0.0.1:7700 |
Meilisearch HTTP endpoint. |
| API key | (empty) | Master key or scoped key. Leave blank in development. |
| Index prefix | flarum |
Distinguish staging/prod on a shared Meilisearch instance. |
| Max hits per query | 500 |
Upper bound on results pulled per index per query. |
How it works
Two Meilisearch indexes (<prefix>_discussions, <prefix>_posts) are kept in sync via event listeners. When a user searches, the gambit queries both indexes, merges the discussion IDs (title hits first, content hits second), and populates most_relevant_post_id so Flarum's existing dropdown can render the matching post snippet automatically.
Async indexing
Live updates are dispatched as Flarum\Queue\AbstractJob instances. Out of the box they run on the sync driver (inline). To move them off the request path, point Flarum at a real queue (e.g. database/Redis) in config.php:
'queue' => ['driver' => 'database'],
and run a worker: php flarum queue:work.
Console
php flarum search:reindex [--chunk=500]
Rebuilds both indexes from MySQL. Safe to run at any time. It re-upserts; documents never leave the indexes unless explicitly deleted.
License
MIT. See LICENSE.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-15