Commit Graph

25 Commits

Author SHA1 Message Date
MauBiBot f72acc60ef Rename blomstra/search fork to sbp/flarum-search (Phase 1: namespaces, routes, JS initializers) 2026-04-22 22:23:47 +02:00
Bart van Bragt d8eebb183a fix: prevent ES CPU saturation from has_child scoring all posts
Without minimum_should_match=1 on the inner post bool query, Elasticsearch
defaults MSM to 0 whenever a filter clause is present. This caused has_child
to score every non-hidden post on every search request, saturating CPU on
shared ES nodes with large corpora (3.7M+ posts).

- Add BoolQuery subclass with create() override and minimumShouldMatch()
  (spatie/elasticsearch-query-builder 1.x uses `new self()` in create(),
  so subclassing requires overriding it)
- Set minimumShouldMatch(1) on the inner post query after adding the
  is_hidden filter, so only genuinely matching posts are scored
- Remove the operator('or') clause from buildShouldClauses() — with
  Turkish min_ngram=2, 'or' generates 2-gram tokens that match nearly
  every post, causing near-total index scans
- Add ES client timeouts (connect: 2s, query: 10s) to prevent Apache
  mod_php worker saturation when ES is slow or unreachable
2026-04-14 16:07:50 +02:00
Bart van Bragt ca8c248870 fix: use Eloquent Collection in job — loadMissing does not exist on Support\Collection 2026-04-14 09:59:02 +02:00
Bart van Bragt e2e2d1428f feat: restructure index as parent-child documents with blue-green rebuilds
- Switch to ES parent/child join_field: discussion docs hold all metadata,
  post docs hold content only. Routing ensures parent and child land on the
  same shard. Removes the old flat-document approach where post data was
  duplicated onto every comment document.

- Add HasChildQuery with inner_hits so the best-matching post ID is
  surfaced as mostRelevantPost without a second DB query.

- Blue-green index rebuilds: --recreate writes into a timestamped pending
  index, --swap atomically promotes it via alias. Interrupted builds are
  resumable with --recreate --continue. --swap requires confirmation before
  proceeding.

- Index hidden posts; non-moderators are filtered at query time via
  is_hidden on the has_child clause. Core\Hidden and Core\Restored trigger
  re-indexing so moderators with post.hide can search hidden posts.
2026-04-09 23:30:57 +02:00
Bart van Bragt 80d66c98c4 feat: index and sync view_count for fof/discussion-views sort support
- Rename SavingJob to UpdateSearchJob
- Add ViewsSearchJob for lightweight partial view_count updates
- Add probabilistic sync throttle in DiscussionSeeder::viewingOn()
  to avoid an ES update on every page view
- Add view_count to mapping, DiscussionSeeder::toDocument(), and
  translateSort
- Log a warning and skip instead of 500ing on unknown sort fields
2026-04-09 12:05:28 +02:00
StyleCI Bot 8b519619e5
Apply fixes from StyleCI 2022-11-24 09:38:21 +00:00
Daniël Klabbers 846cc348ff Merge branch 'dk/search-improvements' into main 2022-11-24 10:29:18 +01:00
StyleCI Bot f8aa3dcf13
Apply fixes from StyleCI 2022-11-18 09:33:13 +00:00
Daniël Klabbers 29ba864849 settings configurations 2022-11-09 18:06:48 +01:00
Daniel Klabbers ca229c8af8 possibly reduce logging 2021-12-13 12:06:26 +01:00
Daniel Klabbers 8111c214cc override api client on the backend to retrieve discussions from elastic always, this prevents all hits to the MySQL db 2021-11-10 12:40:32 +01:00
Daniel Klabbers 4c056a4db4 force queue 2021-11-04 10:47:24 +01:00
Daniel Klabbers c04a9f9861 remove string binding 2021-11-02 13:58:59 +01:00
Daniel Klabbers 47fc5c2f1b refactored jobs, cleaned up 2021-11-02 13:55:41 +01:00
Daniël Klabbers ef4b02b562 Merge branch 'dk/analyzer' into main 2021-10-31 09:17:35 +01:00
Daniël Klabbers 6c045ab595 wip 2021-10-30 13:01:51 +02:00
Daniël Klabbers c3458bf16b allow use of env var UUID for now 2021-10-27 08:59:27 +02:00
Daniel Klabbers 0574307439 refactored 2021-10-20 14:24:44 +02:00
Daniel Klabbers 4fa4ccce99 wip 2021-10-15 21:21:30 +02:00
Daniel Klabbers 4130e49bee wip 2021-10-15 13:51:36 +02:00
Daniel Klabbers 17bb6ff837 moving to posts 2021-10-14 21:31:50 +02:00
Daniel Klabbers 1cb8aac47b support for api key, added readme 2021-10-14 14:53:26 +02:00
Daniel Klabbers f69541d38a moved to elastic 2021-10-14 12:31:45 +02:00
Daniel Klabbers 217e4496be what i have 2021-10-13 20:06:27 +02:00
Daniel Klabbers 2bf4ec01d0 wip 2021-10-12 23:15:47 +02:00