title: Elastic Search reindex API - how to preserve destination index mapping?
body: <p>Let <strong>my-index-0</strong> be an ES index with an alias of <strong>my-index</strong>.</p>
  <p>It has the following mapping:</p>
  <pre class="lang-json prettyprint-override"><code>{
      &quot;my-index-0&quot;: {
          &quot;aliases&quot;: {
              &quot;my-index&quot;: {}
          },
          &quot;mappings&quot;: {
              &quot;doc&quot;: {
                  &quot;properties&quot;: {
                      &quot;foo&quot;: {
                          &quot;properties&quot;: {
                              &quot;fizz&quot;: {
                                  &quot;type&quot;: &quot;keyword&quot;
                              },
                              &quot;baz&quot;: {
                                  &quot;type&quot;: &quot;keyword&quot;
                              }
                          }
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  <p>Let's say I want to remove the <code>baz</code> field from <code>foo</code>. I'm using the following steps:</p>
  <ol>
  <li>Create a new index <code>my-index-1</code> with updated mapping (<code>foo.baz</code> removed) using <code>PUT /my-index-1</code></li>
  </ol>
  <pre class="lang-json prettyprint-override"><code>{
      &quot;mappings&quot;: {
          &quot;doc&quot;: {
              &quot;properties&quot;: {
                  &quot;foo&quot;: {
                      &quot;properties&quot;: {
                          &quot;fizz&quot;: {
                              &quot;type&quot;: &quot;keyword&quot;
                          },
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  <ol start="2">
  <li>Reindex data from <code>my-index-0</code> to <code>my-index-1</code> using <code>POST /_reindex</code></li>
  </ol>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;source&quot;: {
      &quot;index&quot;: &quot;my-index-0&quot;
    },
    &quot;dest&quot;: {
      &quot;index&quot;: &quot;my-index-1&quot;
    }
  }
  </code></pre>
  <ol start="3">
  <li>Move the <code>my-index</code> alias to the <code>my-index-1</code> index using <code>POST /_aliases</code></li>
  </ol>
  <pre class="lang-json prettyprint-override"><code>{
      &quot;actions&quot;: [
          {&quot;remove&quot;: {&quot;index&quot;: &quot;my-index-0&quot;, &quot;alias&quot;: &quot;my-index&quot;}},
          {&quot;add&quot;: {&quot;index&quot;: &quot;my-index-1&quot;, &quot;alias&quot;: &quot;my-index&quot;}},
      ]
  }
  </code></pre>
  <h2>Expected result</h2>
  <p>Data in the new index does not have the <code>foo.baz</code> property.</p>
  <h2>Actual result</h2>
  <p>On <code>my-index-1</code> creation, its mapping does not contain the <code>foo.baz</code> field, however, after re-indexation, <code>my-index-1</code>'s mapping is changed to the old index' mapping.</p>
  <h2>Note: <code>_source</code> can be used for simple fields removal</h2>
  <p>If one wants to remove a field, for example, removal of <code>bar</code> from the mapping below</p>
  <pre class="lang-json prettyprint-override"><code>{
      &quot;mappings&quot;: {
          &quot;foo&quot;: {
              &quot;type&quot;: &quot;text&quot;
          },
          &quot;bar&quot;: {
              &quot;type&quot;: &quot;text&quot;
          }
      }
  }
  </code></pre>
  <p>it is sufficient to provide the <code>_source</code> param without the <code>bar</code> field in the request to reindex API:</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;source&quot;: {
      &quot;index&quot;: &quot;my-index-0&quot;,
      &quot;_source&quot;: [&quot;foo&quot;]
    },
    &quot;dest&quot;: {
      &quot;index&quot;: &quot;my-index-1&quot;
    }
  }
  </code></pre>
  <p>How to achieve the same with a nested structure?</p>