> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mixpeek.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Index 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"
```



## OpenAPI

````yaml get /v1/analytics/namespaces/indexes/recommendations
openapi: 3.1.0
info:
  title: Mixpeek API
  description: >-
    This is the Mixpeek API, providing access to various endpoints for data
    processing and retrieval.
  termsOfService: https://mixpeek.com/terms
  contact:
    name: Mixpeek Support
    url: https://mixpeek.com/contact
    email: info@mixpeek.com
  version: '0.82'
servers:
  - url: https://api.mixpeek.com
    description: Production
security:
  - BearerAuth: []
paths:
  /v1/analytics/namespaces/indexes/recommendations:
    get:
      tags:
        - Analytics
        - Analytics - Namespaces
      summary: Get Index Recommendations
      description: >-
        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"
        ```
      operationId: >-
        get_index_recommendations_v1_analytics_namespaces_indexes_recommendations_get
      parameters:
        - name: days
          in: query
          required: false
          schema:
            type: integer
            maximum: 90
            minimum: 1
            description: Days of history to analyze
            default: 30
            title: Days
          description: Days of history to analyze
        - name: min_usage_count
          in: query
          required: false
          schema:
            type: integer
            maximum: 100
            minimum: 1
            description: Minimum queries to consider
            default: 5
            title: Min Usage Count
          description: Minimum queries to consider
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            maximum: 100
            minimum: 1
            description: Maximum recommendations to return
            default: 50
            title: Limit
          description: Maximum recommendations to return
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IndexRecommendationsResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - BearerAuth: []
          NamespaceHeader: []
components:
  schemas:
    IndexRecommendationsResponse:
      properties:
        namespace_id:
          type: string
          title: Namespace Id
          description: Namespace ID analyzed
        time_range_days:
          type: integer
          title: Time Range Days
          description: Number of days analyzed
        recommendations:
          items:
            $ref: '#/components/schemas/IndexRecommendation'
          type: array
          title: Recommendations
          description: Index recommendations
        summary:
          additionalProperties:
            type: integer
          type: object
          title: Summary
          description: >-
            Summary statistics (high_priority, medium_priority, low_priority
            counts)
        coverage:
          anyOf:
            - $ref: '#/components/schemas/RecommendationCoverage'
            - type: 'null'
          description: >-
            Scope of the recommendations above. An empty list next to a large
            `slow_queries` count means the slow traffic is not filter-driven,
            not that the namespace is healthy. Null when the analytics backend
            could not be read.
      type: object
      required:
        - namespace_id
        - time_range_days
        - recommendations
        - summary
      title: IndexRecommendationsResponse
      description: Response for index recommendations endpoint.
    ErrorResponse:
      properties:
        success:
          type: boolean
          title: Success
          description: Always false for error responses
          default: false
        status:
          type: integer
          title: Status
          description: HTTP status code for this error
        error:
          $ref: '#/components/schemas/ErrorDetail'
          description: Error details payload
      type: object
      required:
        - status
        - error
      title: ErrorResponse
      description: Error response model.
      examples:
        - error:
            details:
              id: ns_123
              resource: namespace
            message: Namespace not found
            type: NotFoundError
          status: 404
          success: false
    IndexRecommendation:
      properties:
        field_name:
          type: string
          title: Field Name
          description: Field to index
        query_count:
          type: integer
          title: Query Count
          description: Number of queries using this field
        avg_latency_ms:
          type: number
          title: Avg Latency Ms
          description: Average latency
        p95_latency_ms:
          type: number
          title: P95 Latency Ms
          description: 95th percentile latency
        slow_query_count:
          type: integer
          title: Slow Query Count
          description: Queries slower than 500ms
        very_slow_query_count:
          type: integer
          title: Very Slow Query Count
          description: Queries slower than 1000ms
        priority_score:
          type: number
          title: Priority Score
          description: Priority score for indexing
        recommendation:
          type: string
          title: Recommendation
          description: Human-readable recommendation level
        mongodb_index_command:
          type: string
          title: Mongodb Index Command
          description: Ready-to-use MongoDB index command
        index_kind:
          anyOf:
            - type: string
            - type: 'null'
          title: Index Kind
          description: >-
            Recommended index KIND, derived from the operators observed with
            this field: 'keyword' (eq/ne/in/nin/exists/is_null), 'range'
            (gt/gte/lt/lte), 'text'
            (contains/starts_with/ends_with/regex/text/phrase/words), 'geo'
            (geo_*). None means no operator data exists for the field (rows
            written before filter_ops shipped) — treat as unknown, not as
            keyword.
      type: object
      required:
        - field_name
        - query_count
        - avg_latency_ms
        - p95_latency_ms
        - slow_query_count
        - very_slow_query_count
        - priority_score
        - recommendation
        - mongodb_index_command
      title: IndexRecommendation
      description: MongoDB index recommendation.
    RecommendationCoverage:
      properties:
        total_queries:
          type: integer
          title: Total Queries
          description: All queries in the window
        filtered_queries:
          type: integer
          title: Filtered Queries
          description: >-
            Queries carrying at least one filter field. These, and only these,
            are what the recommendations above were computed from.
        slow_queries:
          type: integer
          title: Slow Queries
          description: Queries over the slow threshold, filtered or not
        slow_filtered_queries:
          type: integer
          title: Slow Filtered Queries
          description: >-
            Slow queries carrying a filter field. The gap between this and
            `slow_queries` is slow traffic no index recommendation can address —
            look at embedding, vector search or stage cost for those.
        threshold_ms:
          type: number
          title: Threshold Ms
          description: Latency above which a query counts as slow here
          default: 500
      type: object
      required:
        - total_queries
        - filtered_queries
        - slow_queries
        - slow_filtered_queries
      title: RecommendationCoverage
      description: >-
        What share of the namespace's traffic these recommendations were
        computed from.


        Index recommendations are derived only from queries that FILTERED on a

        field (``length(filter_fields) > 0``), since an index is only meaningful
        for

        a filtered field. Without this block an empty ``recommendations`` list
        is

        indistinguishable from "this namespace is fine", and on 2026-08-22 that
        is

        exactly how it read: 184 slow queries in ``ns_7aa8b538a5`` against a

        ``NO ACTION - Low usage`` verdict computed from 8.
    ErrorDetail:
      properties:
        message:
          type: string
          title: Message
          description: Human-readable error message
        type:
          type: string
          title: Type
          description: Stable error type identifier (machine-readable)
        code:
          anyOf:
            - type: string
            - type: 'null'
          title: Code
          description: >-
            Fine-grained error code for programmatic handling (e.g.,
            namespace_name_taken, feature_extractor_not_found). Present only
            when consumers may need to branch on a specific error condition.
        details:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Details
          description: >-
            Optional structured details to help debugging (validation errors,
            IDs, etc.)
      type: object
      required:
        - message
        - type
      title: ErrorDetail
      description: Error detail model.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Mixpeek API key, sent as `Authorization: Bearer mxp_sk_...`. Create one
        in Studio under Settings → API Keys, or with an admin key via `POST
        /v1/organizations/users/{user_email}/api-keys`. A missing, malformed,
        unknown, revoked, inactive or expired key returns 401; a key without the
        permission, scope or plan an operation needs returns 403.
    NamespaceHeader:
      type: apiKey
      in: header
      name: X-Namespace
      description: >-
        Namespace id (`ns_...`), not the namespace name. This scopes the request
        rather than authenticating it, and it is required on every operation
        marked `x-mixpeek-namespace-scoped`.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.