---
title: "Get Index Recommendations"
method: GET
path: "/v1/analytics/namespaces/indexes/recommendations"
tags: ["Analytics", "Analytics - Namespaces"]
---

# Get Index Recommendations

`GET /v1/analytics/namespaces/indexes/recommendations`

Get comprehensive MongoDB index recommendations.

Analyzes query patterns and generates prioritized index recommendations
with ready-to-use MongoDB commands.

**Use Cases:**
- Get actionable index suggestions
- Prioritize database optimization
- Copy/paste index creation commands
- Track optimization opportunities

**Recommendation Levels:**
- **HIGH PRIORITY**: >100 queries, >300ms avg OR >10 very slow queries
- **MEDIUM PRIORITY**: >50 queries, >200ms avg OR >20 slow queries
- **LOW PRIORITY**: >10 queries but acceptable performance
- **NO ACTION**: Low usage, no optimization needed

**Response Includes:**
- Prioritized recommendations
- Usage and latency statistics
- MongoDB index creation commands
- Summary by priority level

**Example:**
```bash
curl -X GET "https://api.mixpeek.com/v1/analytics/namespaces/indexes/recommendations" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "X-Namespace: your-namespace"
```

## Query parameters

- `days` integer — Days of history to analyze
- `min_usage_count` integer — Minimum queries to consider
- `limit` integer — Maximum recommendations to return

## Response `200`

Successful Response

- IndexRecommendationsResponse — Response for index recommendations endpoint.
  - `namespace_id` string, required — Namespace ID analyzed
  - `time_range_days` integer, required — Number of days analyzed
  - `recommendations` IndexRecommendation[], required — Index recommendations
    - `field_name` string, required — Field to index
    - `query_count` integer, required — Number of queries using this field
    - `avg_latency_ms` number, required — Average latency
    - `p95_latency_ms` number, required — 95th percentile latency
    - `slow_query_count` integer, required — Queries slower than 500ms
    - `very_slow_query_count` integer, required — Queries slower than 1000ms
    - `priority_score` number, required — Priority score for indexing
    - `recommendation` string, required — Human-readable recommendation level
    - `mongodb_index_command` string, required — Ready-to-use MongoDB index command
    - `index_kind` string, nullable — Recommended index KIND, derived from the operators observed with this field (BACKE-3394): 'keyword' (eq/ne/in/nin/exists/is_null), 'range' (gt/gte/lt/lte), 'text' (contains/starts_with/ends_with/regex/text/phrase), 'geo' (geo_*). None means no operator data exists for the field (rows written before filter_ops shipped) — treat as unknown, not as keyword.
  - `summary` object, required — Summary statistics (high_priority, medium_priority, low_priority counts)

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `403` — Forbidden
- `404` — Not Found
- `422` — Validation Error
- `500` — Internal Server Error

---

[API](https://skmtc.net/mixpeek/apis/mixpeek-api.md) · [All operations](https://skmtc.net/mixpeek/apis/mixpeek-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/mixpeek/mixpeek-api/revisions/c768d4d28e4c/schema)
