On-write search re-index after catalogue/visibility writes #17
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
The
searchcrate (Plan 6) providesindex_object/remove_object/reindex_all, but on-write sync is not wired — the index is only rebuilt viareindex_all. Plan 7 addedset_visibilityand the public read API, which makes index freshness more visible (a record published/unpublished should appear/disappear from search).Meilisearch is not transactional with Postgres, so this is best-effort eventual consistency;
reindex_allremains the recovery path.What to do
At the API/service layer, after a catalogue create/update/delete/
set_object_fields/set_visibilitycommits:search::SearchClient::index_object(re-project the object) orremove_objectas appropriate;publicmay need to drop from a future public-search index (public search itself is post-MVP —searchalready storesvisibilityas filterable).References
crates/search/src/lib.rs—index_object/remove_object/reindex_all/build_documentcrates/db/src/catalog.rs— the write pathsdocs/plans/2026-06-02-search.md,docs/plans/2026-06-02-publishing-public-api.md(Notes for follow-on plans)Scope note from the admin-CRUD work (merged
main@c4e0c4c): several new catalogue write paths now exist that mutate object data but do not trigger a search re-index, and should be covered by this issue alongside the publish/visibility writes:POST /api/admin/objects(create)PUT /api/admin/objects/{id}(update)DELETE /api/admin/objects/{id}(delete)PUT /api/admin/objects/{id}/fields(flexible-field replace)All live in
crates/api/src/admin_objects.rs. On-write reindexing should hook these in addition to the existingset_visibilitypath.Implemented and merged to
main(d15afda, cosmetic follow-up4921c73).What landed:
search::SearchClient::sync_object(db, id)— one uniform path: re-project +index_objectif the object exists,remove_objectif it's gone. Covers create/update/delete/fields/visibility with a single existence check.AppState.search: Option<SearchClient>+ a best-effortreindex(state, id)helper that logs failures viatracing::error!and never fails the committed write (reindex_allstays the recovery path).create_object,update_object(when existed),delete_object(when existed),set_fields,set_visibility— success branches only.MEILI_URL/MEILI_MASTER_KEY/MEILI_INDEX(defaultobjects); indexing enabled only when URL+key are set, else disabled with a warn (no-op).search/tests/sync.rs(index-then-remove) andapi/tests/reindex.rs(HTTP create → indexed, delete → removed). Full workspace green.Follow-up filed for the inline-reindex latency (background task). Closing.