meilisearch/MeiliSearch

Error message for `max_fields_limit_exceeded` is misleading

Open

#5508 opened on Apr 14, 2025

View on GitHub
 (3 comments) (0 reactions) (0 assignees)Rust (20,887 stars) (733 forks)batch import
buggood first issueimpacts docs

Description

Describe the bug The error message for max_fields_limit_exceeded does not state the precise issue that is being encountered.

To Reproduce Steps to reproduce the behavior:

  1. Add one document with 65,535 unique fields
  2. Add a second document with a new unique field
  3. The second task fails with the error code max_fields_limit_exceeded, stating: A document cannot contain more than 65,535 fields., although the second document only has a single field

Expected behavior

  • Correctly state the actual rules that are implemented.
  • Update the documentation on limitations to match the actual rules.
  • Update the documentation to document the max_fields_limit_exceeded error code, which isn't correctly the case.

Actual rules

  1. Unique fields across all documents are counted from 0 to 65,534
  2. A single index cannot have more than 65,535 unique fields across all documents
  3. Removing a field from all documents does not restore a free slot; once all fields are exhausted one should instead create a new index or at least clear all documents. Updating through a dump also restores the free slots
  4. While the error code is not documented, the limitation is. However, the explanation is wrong as the limit is for unique fields across all documents of an index, not for a single document.
  5. As the number of unique fields increases, the performance of Meilisearch decreases. It is not recommended to have "many" unique fields in an index.

Suggestion for the new error message

Adding the document with id document_id would add 1 new unique field to the index, exceeding the limit of 65,535 unique fields in the index.

  • note: prior to this batch of tasks, the index already contained 65,535 unique fields.
  • note: other documents from the same batch might have successfully added new unique fields before this one.

Meilisearch version: v1.14.0

Additional context Internal issue comment: https://github.com/meilisearch/meilisearch-support/issues/829#issuecomment-2801044022

@meilisearch/docs-team

Contributor guide