title: NodeJS - Elastic Search for insert data to index
body: <p>I followed <a href="https://ciphertrick.com/elasticsearch-and-nodejs-tutorial/" rel="nofollow noreferrer">this link</a> to get the mapping of the Elastic Search Index and would like to insert data(not include all fields) into it as below, but failed.</p>
  
  <p>Mapping of index:</p>
  
  <pre><code>{
      "mymapping": {
          "mappings": {
              "_meta": {
                  "beat": "apm",
                  "version": "7.5.0"
              },
              "dynamic_templates": [
                  {
                      "labels": {
                          "path_match": "labels.*",
                          "match_mapping_type": "string",
                          "mapping": {
                              "type": "keyword"
                          }
                      }
                  }
              ],
              "properties": {
                  "@timestamp": {
                      "type": "date"
                  },
                  "people": {
                      "dynamic": "false",
                      "properties": {
                          "id": {
                              "type": "keyword",
                              "ignore_above": 1024
                          },
                          "name": {
                              "type": "keyword",
                              "ignore_above": 1024
                          }
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>I prepared client.js without problem, here is InsertData.js:</p>
  
  <pre><code>const esClient = require('./client');
  const insertDoc = async function(indexName, _id, mappingType, data){
      return await esClient.index({
          index: indexName,
          type: mappingType,
          id: _id,
          body: data
      });
  }
  
  module.exports = insertDoc;
  async function test(){
      const data = {
          beat: 'apm',
          version: '7.5.0'
      }
      try {
          const resp = await insertDoc('mymapping', 2, '_meta', data);
          console.log(resp);
      } catch (e) {
          console.log(e);
      }
  }
  test();
  </code></pre>
  
  <p>When I tried to insert data, there was exception.
  Error output:</p>
  
  <pre><code>message:  
  '[illegal_argument_exception] Rejecting mapping update to [mymapping] as the final mapping would have more than 1 type: [_doc, _meta]',  
  path: '/mymapping/_doc/2',  
  query: { type: '_meta' },  
  body:  
  { error:  
      { root_cause: [Array],  
      type: 'illegal_argument_exception',  
      reason:  
          'Rejecting mapping update to [mymapping] as the final mapping would have more than 1 type: [_doc, _meta]' },  
      status: 400 },  
  statusCode: 400,  
  response:  
  '{  
      "error": {  
          "root_cause": [  
              {  
                  "type": "illegal_argument_exception",  
                  "reason": "Rejecting mapping update to [mymapping] as the final mapping would have more than 1 type: [_doc, _meta]"  
              }  
          ],  
          "type": "illegal_argument_exception",  
          "reason": "Rejecting mapping update to [mymapping] as the final mapping would have more than 1 type: [_doc, _meta]"  
      },  
      "status": 400  
  }'  
  </code></pre>
  
  <p>How can insert data properly?</p>