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

# Configure search cutoff

> Set a maximum search time to ensure consistent response times for large datasets.

The search cutoff defines the maximum time in milliseconds that Meilisearch spends processing a single search query. When the cutoff is reached, Meilisearch stops searching and returns the best results found so far. This ensures predictable response times on large datasets where some queries might otherwise take too long.

## How it works

When a search query is processed, Meilisearch iterates through documents and [ranking rules](/capabilities/full_text_search/relevancy/ranking_rules) to find and rank the best matches. On very large datasets (millions of documents) or with broad queries, this process can take significant time.

The search cutoff sets an upper bound on this processing time. If Meilisearch reaches the cutoff before finishing, it returns the results collected up to that point. These results are still ranked correctly according to the ranking rules, but the result set may not include every possible match.

By default, `searchCutoffMs` is `null`. When no explicit value is configured, Meilisearch interrupts searches after **1500 milliseconds**. Setting `searchCutoffMs` to an integer overrides this internal default with your chosen limit.

## Check current search cutoff

Retrieve the current `searchCutoffMs` setting for an index:

<CodeGroup>
  ```bash cURL theme={null}
  curl \
    -X GET 'MEILISEARCH_URL/indexes/movies/settings/search-cutoff-ms'
  ```

  ```javascript JS theme={null}
  client.index('movies').getSearchCutoffMs()
  ```

  ```python Python theme={null}
  client.index('movies').get_search_cutoff_ms()
  ```

  ```php PHP theme={null}
  $client->index('movies')->getSearchCutoffMs();
  ```

  ```java Java theme={null}
  client.index("movies").getSearchCutoffMsSettings();
  ```

  ```ruby Ruby theme={null}
  client.index('movies').search_cutoff_ms
  ```

  ```go Go theme={null}
  client.Index("movies").GetSearchCutoffMs()
  ```

  ```csharp C# theme={null}
  var searchCutoff = await client.Index("movies").GetSearchCutoffMsAsync();
  ```

  ```rust Rust theme={null}
  let search_cutoff_ms: String = client
    .index("movies")
    .get_search_cutoff_ms()
    .await
    .unwrap();
  ```

  ```swift Swift theme={null}
  let precisionValue = try await self.client.index("books").getSearchCutoffMs()
  ```
</CodeGroup>

The default response is `null`.

## Set a search cutoff

Configure a maximum search time of 150 milliseconds:

<CodeGroup>
  ```bash cURL theme={null}
  curl \
    -X PUT 'MEILISEARCH_URL/indexes/movies/settings/search-cutoff-ms' \
    -H 'Content-Type: application/json' \
    --data-binary '150'
  ```

  ```javascript JS theme={null}
  client.index('movies').updateSearchCutoffMs(150)
  ```

  ```python Python theme={null}
  client.index('movies').update_search_cutoff_ms(150)
  ```

  ```php PHP theme={null}
  $client->index('movies')->updateSearchCutoffMs(150);
  ```

  ```java Java theme={null}
  client.index("movies").updateSearchCutoffMsSettings(150);
  ```

  ```ruby Ruby theme={null}
  client.index('movies').update_search_cutoff_ms(150)
  ```

  ```go Go theme={null}
  client.Index("movies").UpdateSearchCutoffMs(150)
  ```

  ```csharp C# theme={null}
  await client.Index("movies").UpdateSearchCutoffMsAsync(150);
  ```

  ```rust Rust theme={null}
  let task: TaskInfo = client
    .index("movies")
    .set_search_cutoff_ms(Some(150))
    .await
    .unwrap();
  ```

  ```swift Swift theme={null}
  let task = try await self.client.index("books").updateSearchCutoffMs(150)
  ```
</CodeGroup>

With this configuration, any search query that takes longer than 150ms will be interrupted, and Meilisearch returns the best results found within that time.

<Warning>
  Setting the cutoff too low may result in incomplete or empty result sets for broad queries. Start with a value between 100ms and 500ms and adjust based on your performance requirements.
</Warning>

## Reset search cutoff

Remove the explicit search cutoff and return to the default behavior (`searchCutoffMs: null`, with Meilisearch's internal 1500 ms interruption threshold):

<CodeGroup>
  ```bash cURL theme={null}
  curl \
    -X DELETE 'MEILISEARCH_URL/indexes/movies/settings/search-cutoff-ms'
  ```

  ```javascript JS theme={null}
  client.index('movies').resetSearchCutoffMs()
  ```

  ```python Python theme={null}
  client.index('movies').reset_search_cutoff_ms()
  ```

  ```php PHP theme={null}
  $client->index('movies')->resetSearchCutoffMs();
  ```

  ```java Java theme={null}
  client.index("movies").resetSearchCutoffMsSettings();
  ```

  ```ruby Ruby theme={null}
  client.index('movies').reset_search_cutoff_ms
  ```

  ```go Go theme={null}
  client.Index("books").ResetSearchCutoffMs()
  ```

  ```csharp C# theme={null}
  await client.Index("movies").ResetSearchCutoffMsAsync();
  ```

  ```rust Rust theme={null}
  let task: TaskInfo = client
    .index("movies")
    .reset_search_cutoff_ms()
    .await
    .unwrap();
  ```

  ```swift Swift theme={null}
  let task = try await self.client.index("books").resetSearchCutoffMs()
  ```
</CodeGroup>

## Choosing a cutoff value

The right cutoff value is a trade-off: lower values guarantee faster responses but increase the chance of returning incomplete results for broad queries. Higher values give Meilisearch more time to find all matches but allow occasional slow queries.

As a general recommendation, avoid setting the cutoff below **500ms**. This provides a good safety net against unusually long queries (including potential abuse from crafted search strings) while still giving Meilisearch enough time to return quality results for the vast majority of queries.

<Tip>
  The cutoff is most useful as a safety net, not as a performance tuning knob. If your searches are consistently slow, address the root cause with the optimizations below rather than lowering the cutoff.
</Tip>

## Search cutoff vs. other performance optimizations

The search cutoff is a reactive measure that limits query time after it becomes a problem. For proactive performance improvements, consider:

* [Configuring searchable attributes](/capabilities/full_text_search/how_to/configure_searchable_attributes) to reduce the number of fields Meilisearch scans
* [Configuring stop words](/capabilities/full_text_search/how_to/configure_stop_words) to eliminate common terms from indexing
* [Disabling prefix search](/capabilities/full_text_search/how_to/configure_prefix_search) if search-as-you-type is not needed

These optimizations reduce the work Meilisearch does during each query, which may eliminate the need for a cutoff entirely.

<Info>
  For the full API reference, see [get search cutoff](/reference/api/settings/get-searchcutoffms).
</Info>
