meilisearch/MeiliSearch
View on GitHubError message for `max_fields_limit_exceeded` is misleading
Open
#5508 opened on Apr 14, 2025
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:
- Add one document with 65,535 unique fields
- Add a second document with a new unique field
- 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_exceedederror code, which isn't correctly the case.
Actual rules
- Unique fields across all documents are counted from 0 to 65,534
- A single index cannot have more than 65,535 unique fields across all documents
- 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
- 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.
- 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