1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// SPDX-FileCopyrightText: Szilárd Hajba
// SPDX-License-Identifier: LGPL-3.0-or-later
//! `POST /api/search/reindex` — rebuilding one tenant's index by hand.
//!
//! The index maintains itself: every write path asks for the object it just
//! wrote to be re-indexed, and [`crate::reindex`] sweeps weekly and on startup.
//! This exists for the cases where waiting is not acceptable — an owner who
//! suspects a write path forgot its `search_index_object` call and wants the
//! answer now rather than on Sunday.
//!
//! Gated by `require_leader` in `cloudillo/src/routes/protected.rs`: rebuilding
//! your own tenant's index is an ordinary owner operation, but a sweep re-reads
//! every file, profile and action of that tenant, which is not something an
//! ordinary member should be able to start. The scope is always the calling
//! tenant — the whole-node sweep ([`crate::reindex::ReindexScope::All`]) is
//! reachable only from the weekly recurring task, never from a request.
//!
//! The 202 only says the sweep was scheduled. The outcome arrives separately, as
//! a `SEARCH_REINDEX_DONE` message broadcast to the tenant's WebSocket bus
//! connections when the sweep ends — see [`crate::reindex`].
use ;
use ApiResponse;
use Serialize;
use crate::;
/// POST /api/search/reindex — rebuild the calling tenant's full-text index.
///
/// Scheduled rather than run inline: a sweep is proportional to the tenant's
/// data and would hold the request open for minutes. It runs unconditionally —
/// this is not the startup path, so the stored `search.index_rev` does not gate
/// it — and logs what it touched at `info` when it finishes.
///
/// The same counts also go to the caller: the task pushes `SEARCH_REINDEX_DONE`
/// to this tenant's bus connections when it finishes, so the client need not poll
/// a `taskId` that has no endpoint behind it. A failure sends one message too, on
/// the first failed attempt, and then stays silent for the nine retries.
///
/// The scheduler's key dedup means calling this repeatedly coalesces into one
/// pending run per tenant rather than queueing a sweep per request.
pub async
// vim: ts=4