title: Easticsearch reindexing multi-type parent/child index(v5.0) to join type index(v6.2)
body: <p>I am reindexing my index data from ES 5.0(parent-child) to ES 6.2(Join type)</p>
  
  <p>Data in index ES 5.0 is stored as parent-child documents in separate types and for reindex i have created new index/mapping based on 6.2 in my new cluster.</p>
  
  <p>The parent documents flawlessly reindex to new index but the child documents throwing error as below</p>
  
  <pre><code>{
    "index": "index_two",
    "type": "_doc",
    "id": "AVpisCkMuwDYFnQZiFXl",
    "cause": {
      "type": "mapper_parsing_exception",
      "reason": "failed to parse",
      "caused_by": {
        "type": "illegal_argument_exception",
        "reason": "[routing] is missing for join field [field_relationship]"
      }
    },
    "status": 400
  }
  </code></pre>
  
  <p>scripts i am using to reindex the data</p>
  
  <pre><code>  {
    "source": {
      "remote": {
        "host": "http://myescluster.com:9200",
        "socket_timeout": "1m",
        "connect_timeout": "20s"
      },
      "index": "index_two",
      "type": ["actions"],
      "size": 5000,
      "query":{
          "bool":{
              "must":[
                  {"term": {"client_id.raw": "cl14ous0ydao"}}
              ]
          }
      }
    },
    "dest": {
      "index": "index_two",
      "type": "_doc"
    },
    "script": {
      "params": {
          "jdata": {
              "name": "actions"
          }
      },
      "source": "ctx._routing=ctx._routing;ctx.remove('_parent');params.jdata.parent=ctx._source.user_id;ctx._source.field_relationship=params.jdata"
    }
  }
  </code></pre>
  
  <p>I have passed the routing field in painless script as the documents are dynamic from source index.</p>
  
  <p>Mapping of the destination index</p>
  
  <pre><code>{
    "index_two": {
      "mappings": {
        "_doc": {
          "dynamic_templates": [
            {
              "template_actions": {
                "match_mapping_type": "string",
                "mapping": {
                  "fields": {
                    "raw": {
                      "index": true,
                      "ignore_above": 256,
                      "type": "keyword"
                    }
                  },
                  "type": "text"
                }
              }
            }
          ],
          "date_detection": false,
          "properties": {
            "attributes": {
              "type": "nested"
            }
          },
          "cl_other_params": {
            "type": "nested"
          },
          "cl_triggered_ts": {
            "type": "date"
          },
          "cl_utm_params": {
            "type": "nested"
          },
          "end_ts": {
            "type": "date"
          },
          "field_relationship": {
            "type": "join",
            "eager_global_ordinals": true,
            "relations": {
              "users": [
                "actions",
                "segments"
              ]
            }
          },
          "ip_address": {
            "type": "ip"
          },
          "location": {
            "type": "geo_point"
          },
          "processed_ts": {
            "type": "date"
          },
          "processing_time": {
            "type": "date"
          },
          "products": {
            "type": "nested",
            "properties": {
              "traits": {
                "type": "nested"
              }
            }
          },
          "segment_id": {
            "type": "integer"
          },
          "start_ts": {
            "type": "date"
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>My sample source document</p>
  
  <pre><code>    {
      "_index": "index_two",
      "_type": "actions",
      "_id": "AVvKUYcceQCc2OyLKWZ9",
      "_score": 7.4023576,
      "_routing": "cl14ous0ydaob71ab2a1-837c-4904-a755-11e13410fb94",
      "_parent": "cl14ous0ydaob71ab2a1-837c-4904-a755-11e13410fb94",
      "_source": {
        "user_id": "cl14ous0ydaob71ab2a1-837c-4904-a755-11e13410fb94",
        "client_id": "cl14ous0ydao",
        "session_id": "CL-e0ec3941-6dad-4d2d-bc9b",
        "source": "betalist",
        "action": "pageview",
        "action_type": "pageview",
        "device": "Desktop",
        "ip_address": "49.35.14.224",
        "location": "20.7333 , 77",
        "attributes": [
          {
            "key": "url",
            "value": "https://www.google.com/",
            "type": "string"
          }
        ],
        "products": []
      }
    }
  </code></pre>