Question: I have an index with the name 'dev-steps', 

mapping for this index:

```
    {
        "dev-steps": {
          "mappings": {
            "steps": {
              "properties": {
                "cId": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword",
                      "ignore_above": 256
                    }
                  }
                },
                "data": {
                  "properties": {
                    "ui034": {
                        "type": "long"
                    },
                    "ksms5": {
                        "type": "long"
                    },
                    "ui0tg": {
                        "type": "long"
                    },
                    "vcw5d": {
                        "type": "long"
                    }
                  }
                },
                "uId": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword",
                      "ignore_above": 256
                    }
                  }
                }
              }
            }
          }
        }
      }

```

I see a problem, any time when I add new value to the field 'data', that add a new property to the mapping; how I can create a dynamic mapping?

Answer: 
Not quite. Static variables are initialised *the first time* they are encountered, which of course is not necessarily at the start of a function.
I think, based on your comments, that the detail you are missing is that there are both global and local static variables.

Global static variables are initialized when the program is first loaded. Edit: Apparently this is not required behavior (though it is the most common) - initialization is allowed to be delayed. See comment by @walnut.

Example:

```
int main()
{
    std::cout << "start program!" << std::endl;
    return 0;
}

static Base b;

```

Output:

```
I'm Base
start program!

```

While static variables in functions are initialized the first time control passes over them. Example:

```
int main()
{
    std::cout << "start program!" << std::endl;
    static Base b;
    return 0;
}

```

Output:

```
start program!
I'm Base

```

I have added a second example, as per @EvilTeach's comment, to show how the static is only initialized a single time despite multiple functioncalls. Also, added guard (from @eerorika's answer) to show how initialization only happens when execution actually reaches the variable.

```
void testFunc(bool test)
{
    std::cout << "testFunc called with: " << test << std::endl;
    if (test)
        static Base b;
}

int main()
{
    testFunc(false);
    testFunc(true);
    testFunc(true);
    return 0;
}

```

Output:

```
testFunc called with: 0
testFunc called with: 1
I'm Base
testFunc called with: 1

```