title: Why can't I mix my data types in Elasticsearch?
body: <p>Currently, I'm trying to implement a variation of the car example here:</p>
  
  <p><a href="https://www.elastic.co/blog/managing-relations-inside-elasticsearch" rel="nofollow noreferrer">https://www.elastic.co/blog/managing-relations-inside-elasticsearch</a></p>
  
  <p>If I run:</p>
  
  <pre><code>PUT /vehicle/_doc/1
  {  
     "metadata":[  
        {  
           "key":"make",
           "value":"Saturn"
        },
        {  
           "key":"year",
           "value":"2015"
        }
     ]
  }
  </code></pre>
  
  <p>the code works correctly.</p>
  
  <p>But if I delete the index and change 2015 from a string to a number:</p>
  
  <pre><code>DELETE /vehicle
  PUT /vehicle/_doc/1
  {  
     "metadata":[  
        {  
           "key":"make",
           "value":"Saturn"
        },
        {  
           "key":"year",
           "value":2015
        }
     ]
  }
  </code></pre>
  
  <p>I get the following error message:</p>
  
  <blockquote>
    <p>{   "error": {
        "root_cause": [
          {
            "type": "illegal_argument_exception",
            "reason": "mapper [metadata.value] of different type, current_type [long], merged_type [text]"
          }
        ],
        "type": "illegal_argument_exception",
        "reason": "mapper [metadata.value] of different type, current_type [long], merged_type [text]"   },   "status": 400 }</p>
  </blockquote>
  
  <p>How do I fix this error?</p>