Preview, run or cancel a search-index rebuild
reindexPreview, start, or cancel a rebuild of the local search index when search results report incomplete coverage; mail, flags, and folders are never changed.
Instructions
Preview, start or cancel a full rebuild of the local search index, chosen by op; mail, flags and folders are never changed.
Use it when search results report incomplete index coverage (index_note, index_status) or the user asks for a rebuild. Check reindex_status first: it reports progress and changes nothing. A rebuild only reads mail and writes a separate local candidate index.
op="preview" takes no other argument and starts nothing. It returns current indexed and All Mail counts, missing count, ETA, log_id and a single-use token that expires after five minutes. Present it for explicit user approval; reindex has no form. Counts describe All Mail; ETA also includes LIST-vetted real-folder copies, from their STATUS counts. Label views are excluded.
op="execute" takes only token: only call after the user explicitly approved the preview. It returns log_id and run_id at once while the rebuild runs in the background; poll reindex_status. One rebuild runs at a time: an already running refusal includes its run_id and never queues another. Search keeps using the old index. A separate read-only IMAP connection reads All Mail and real folders at a capped rate, and rechecks folder UIDVALIDITY and live inventories before the final All Mail validation. The candidate replaces the live index only at >=99% of the current All Mail count; otherwise, or after any folder error or a cancellation, the old index stays and status says why.
op="cancel" takes only run_id, from op="execute" or reindex_status: it stops that rebuild and discards its candidate, keeping the old index. Poll reindex_status until the run reports cancelled.
Any other mix of arguments refuses. An expired or used token refuses: preview again.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| op | Yes | preview takes no other argument, execute takes only token and cancel takes only run_id. | |
| token | No | With op="execute": the token from the preview the user approved. | |
| run_id | No | With op="cancel": the run_id from op="execute" or reindex_status. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||