Dynamic mapping types

Greetings,
I am new here, using Elasticsearch 6.3, and I am facing the following problem when aiming to migrate 10GB of data. What I want to achieve, is to save all data its being sent, but only be able to searchable for the *_s fields.
When saving data without strict mode, it caused my mapping to grow enormously, one mapping per new value added, so I assume it will eventually cause a mapping explosion.
As a small example of my mapping is as follows:

{
    "mappings" : {
     "_doc" : {
      "dynamic": "strict",
      "dynamic_templates" : [
       {
        "template_s" : {
         "match" : "*_s",
         "match_mapping_type" : "string",
         "mapping" : { "type" : "text", "store" : true }
        }
       },
       {
        "template_" : {
         "match" : "*",
         "match_mapping_type" : "object",
         "mapping" : { "type" : "string", "store": true, "enabled": false }
        }
       }]
      }
    }
  }

On the other hand, this is a sample of the data being sent, on the one I am experiencing an error, mapping set to strict, dynamic introduction of [data_s] within [_doc] is not allowed is:

    {"index":{"_id": "0131d3d0-3837-4fa8-a893-12d0521f1727"}}
    {"data_s": "value", "settings":{"type":"github"}}

I've also tried with match_mapping_type on string in the "catch all" and strings|text on mapping and all of their derivates.
In conclusion, how do I make a mapping that uses all _s fields for search, and excludes the other ones by only saving them without making an enormous mapping? They can be Objects and Objects inside objetcs so my mapping will get very big.

On a side note, maybe the mapping growing enormously is not a concern, just to have an idea, when I saved 15 values my mapping growed to 2k lines, so I imagine this will be a problem when migrating everything, is this correct?

Much appreciated! Thank you for your patience.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.