opensearch-project / OpenSearch

🔎 Open source distributed and RESTful search engine.
https://opensearch.org/docs/latest/opensearch/index/
Apache License 2.0
9.62k stars 1.76k forks source link

[RFC] Unmap the fields which would make the mapping exceeds the total fields limit or depth limit #14031

Open gaobinlong opened 4 months ago

gaobinlong commented 4 months ago

Is your feature request related to a problem? Please describe

This idea originates from https://github.com/opensearch-project/OpenSearch/issues/13089.

In log analytics scenario, it's common to see so many mapped fields in an index, dynamic mapping is commonly used to make new detected fields being added to the mapping automatically, but in order to avoid mapping explosion, we have some index level mapping limit, such as index.mapping.total_fields.limit which defaults to 1000, and index.mapping.depth.limit which defaults to 20.

However, when the mapping limit breaches, all of the following indexing requests containing new detected fields will fail with an error Limit of total fields [1000] has been exceeded, a temporary solution about this problem is to increase the limit manually, but once the new limit breaches, users have to increase the limit again, that is not practical.

Describe the solution you'd like

We can give users an option to let them control the behavior when the mapping exceeds the limit, one option is that we do not index the new detected fields, just like set dynamic: false to the index mapping, new detected fields are not added to the mapping, and also not indexed, not searchable but still be stored in _source, so that the indexing request won't fail, and users can still see the unmapped fields in the document.

Because the mapping limit are index level, I think we can also add some index level settings to control the behavior when the limit breaches, something like this:

PUT test-index
{
  "settings": {
    "index.mapping.total_fields.limit":1000,
    "index.mapping.total_fields.unmap_fields_beyond_limit":true,
    "index.mapping.depth.limit":20,
    "index.mapping.depth.unmap_fields_beyond_limit":true
  }
}

Related component

Indexing

Describe alternatives you've considered

No response

Additional context

No response

andrross commented 3 months ago

[Triage - attendees 1 2 3 4 5]

Thanks for filing @gaobinlong. Looking forward to seeing more discussion here.