How to limit mapping size?

In my use case, my users can dynamically add fields to the documents I store which of course effect the mapping.
Here is an example document:

    "field1": "value",
    "field2": "value",
    "field3": "value",
    "custom": {
        "my_new_field1": "value",
        "my_new_field2": "value"

My users can add fields under the custom key. My problem is that it can be pretty much endless..
Is there any suggestions to how do I need to manage ES in such a use case?

I thought maybe to create 10 custom fields for string and 10 for int, and map them in my code, so the size of 20 fields will not grow, in this case every user will have 20 fields top.

Is there any other idea? does it make sense?

The only way is to disable dynamic mapping.

Starting in 5.0.0 it will be possible to limit the number of fields: #17357

Thanks @jasontedor!