Skip to content

Index Management โ€‹

MongoDB index inspection and maintenance. Each model the platform stores has an expected set of indexes (declared via Settings.indexes, Indexed() annotations, or index_helper suggestions); these endpoints let an operator audit what's currently present in MongoDB versus what's expected, clean up dead indexes, and rebuild missing ones.

Scopes โ€‹

ScopeReach
adminAll index-management endpoints.

Endpoints โ€‹

List Models โ€‹

GET /api/admin/indexes/models

Returns every model name the index manager knows about. The model names returned here are the values to pass as {model_name} on the other endpoints.

Required scope: admin ยท also accepts API key

Response 200 โ€” list of model identifiers.

Get Index Status โ€‹

GET /api/admin/indexes/{model_name}/status

Returns a comprehensive snapshot of the model's index situation, including:

  • Expected indexes โ€” declared via Settings.indexes, Indexed() annotations, or fields marked use_in_query=True.
  • Actual indexes โ€” what currently exists in MongoDB.
  • Dead indexes โ€” exist in MongoDB but no longer expected.
  • Missing indexes โ€” expected but not present.
  • Coverage report โ€” quick summary of healthy / unhealthy state.
  • Suggested indexes โ€” heuristic recommendations from index_helper.

Required scope: admin ยท also accepts API key

Path parameters

NameTypeRequiredDescription
model_namestringyesModel name (see List Models).

Response 200 โ€” IndexStatusResponse

Clean Up Dead Indexes โ€‹

POST /api/admin/indexes/{model_name}/cleanup

Removes indexes that exist in MongoDB but are not expected (not declared, not annotated, not suggested). Defaults to dry-run mode โ€” pass dry_run=false to actually remove indexes.

Required scope: admin

Path parameters

NameTypeRequiredDescription
model_namestringyesModel name.

Query parameters

NameTypeDefaultDescription
dry_runbooleantrueWhen true, report what would be removed without actually doing it.

Response 200 โ€” CleanupResponse

Recreate Missing Indexes โ€‹

POST /api/admin/indexes/{model_name}/recreate

Creates any expected indexes that are currently missing from MongoDB. Does not touch existing indexes.

Required scope: admin

Path parameters

NameTypeRequiredDescription
model_namestringyesModel name.

Response 200 โ€” RecreateResponse

Recreate All Indexes (Drop & Recreate) โ€‹

POST /api/admin/indexes/{model_name}/recreate-all

Drops every index on the model (except _id_) and recreates them all. Use this when the index set has drifted significantly or when you suspect a corrupted index โ€” it is the heavier hammer compared to /recreate.

Required scope: admin

Path parameters

NameTypeRequiredDescription
model_namestringyesModel name.

Response 200 โ€” RecreateResponse

WARNING

Dropping and recreating indexes can cause temporary read-performance degradation while MongoDB rebuilds them. Run during a maintenance window for large collections.

See also โ€‹

S-Launch