title: how to mapping join type by using spring data elasticSearch
body: <p>i reindex data from es 2.4 to 5.6.<br>
  data in es 2.4 have 2 types,and the 2 type is parent-child relation.<br>
  when reindex it to es 5.6,the index only contains single type,the parent-child relation by using join type to resolving.<br>
  the data above works ok.
  the mapping example like this, it contains a join type:</p>
  
  <pre><code>"mappings": {
      "doc": {
          "properties": {
              "my_join_field": {
                  "eager_global_ordinals": true,
                  "type": "join",
                  "relations": {
                      "question": "answer"
                  }
              },
              "name": {
                  "type": "text",
                  "fields": {
                      "keyword": {
                          "ignore_above": 256,
                          "type": "keyword"
                      }
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>how to mapping join type by using spring data elasticSearch:
  in old version code es 2.4,i can mapping it like this:</p>
  
  <pre><code>@Document(indexName = ParentEntity.INDEX, type = ParentEntity.PARENT_TYPE, shards = 1, replicas = 0, refreshInterval = "-1")
  public class ParentEntity {
  
      public static final String INDEX = "parent-child";
      public static final String PARENT_TYPE = "parent-entity";
      public static final String CHILD_TYPE = "child-entity";
  
      @Id
      private String id;
      @Field(type = FieldType.Text, store = true)
      private String name;
  
      public ParentEntity() {
      }
  
      public ParentEntity(String id, String name) {
          this.id = id;
          this.name = name;
      }
  
      public String getId() {
          return id;
      }
  
      public String getName() {
          return name;
      }
  
      @Override
      public String toString() {
          return new ToStringCreator(this).append("id", id).append("name", name).toString();
      }
  
      @Document(indexName = INDEX, type = CHILD_TYPE, shards = 1, replicas = 0, refreshInterval = "-1")
      public static class ChildEntity {
  
          @Id
          private String id;
          @Field(type = FieldType.Text, store = true)
          @Parent(type = PARENT_TYPE)
          private String parentId;
          @Field(type = FieldType.Text, store = true)
          private String name;
  
          public ChildEntity() {
          }
  
          public ChildEntity(String id, String parentId, String name) {
              this.id = id;
              this.parentId = parentId;
              this.name = name;
          }
  
          public String getId() {
              return id;
          }
  
          public String getParentId() {
              return parentId;
          }
  
          public String getName() {
              return name;
          }
  
          @Override
          public String toString() {
              return new ToStringCreator(this).append("id", id).append("parentId", parentId).append("name", name).toString();
          }
      }
  }
  </code></pre>
  
  <p>how can i Mapping join type by using spring data elasticSearch v3.0.10?</p>
  
  <p>Today, i tried the entity below to working  at spring data elasticSearch 3.0.10:</p>
  
  <pre><code>@Document(indexName = "join_index", type = "join_mapping")
  @Data
  public class JoinEntity {
      @Id
      private String id;
      @Mapping(mappingPath = "/mappings/join_type.json")
      private Map&lt;String,String&gt; relationType;
      @Field(type = FieldType.Keyword)
      private String name;
      //@Parent(type = "question")
      @Field(type = FieldType.Keyword)
      private String parentId;
  }
  </code></pre>
  
  <p>join_type.json below:</p>
  
  <pre><code>{
    "type": "join",
    "relations": {
      "question": "answer"
    }
  }
  </code></pre>
  
  <p>it create index and put mapping work ok:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration("classpath:elasticsearch-template-test.xml")
  public class ElasticsearchTemplateJoinTests {
  
      @Autowired
      private ElasticsearchTemplate elasticsearchTemplate;
  
      @Before
      public void before() {
          clean();
          elasticsearchTemplate.deleteIndex(JoinEntity.class);
          elasticsearchTemplate.createIndex(JoinEntity.class);
          elasticsearchTemplate.putMapping(JoinEntity.class);
          elasticsearchTemplate.refresh(JoinEntity.class);
      }
  
      @Test
      public void shouldCreateIndexAndMappingSuccess(){
          Map mapping = elasticsearchTemplate.getMapping(JoinEntity.class);
          assertThat(mapping, is(notNullValue()));
  
          Map properties = (Map) mapping.get("properties");
          assertThat(properties, is(notNullValue()));
  
          assertThat(properties.containsKey("name"), is(true));
          Map file = (Map) properties.get("relationType");
          assertThat(file, is(notNullValue()));
          assertThat(((String) file.get("type")), is("join"));
      }
  }
  </code></pre>
  
  <p>when index parent work ok too,but index child it throws exception:</p>
  
  <pre><code>@Test 
  public void shouldIndexParentAndChildSuccess(){
      JoinEntity parenEntity = new JoinEntity();
      parenEntity.setName("parent_name");
      parenEntity.setRelationType(Collections.singletonMap("name","question"));
      IndexQuery parentQuery = new IndexQueryBuilder().withId("11").withObject(parenEntity).build();
      final String id = elasticsearchTemplate.index(parentQuery);
      assertThat("11",is(id));
      JoinEntity childEntity = new JoinEntity();
      childEntity.setName("child_name");
      Map&lt;String,String&gt; joinRelation = new HashMap&lt;&gt;(2);
      joinRelation.put("name","answer");
      joinRelation.put("parent", "11");
      childEntity.setRelationType(joinRelation);
      childEntity.setParentId("11");
      IndexQuery childQuery = new IndexQueryBuilder().withId("22").withObject(childEntity).build();
      elasticsearchTemplate.index(childQuery);
  }
  </code></pre>
  
  <p>exception:</p>
  
  <pre><code>MapperParsingException[failed to parse
  ]; nested: IllegalArgumentException[[routing] is missing for join field [relationType]];
      at org.elasticsearch.index.mapper.DocumentParser.wrapInMapperParsingException(DocumentParser.java:171)
  </code></pre>
  
  <p>how can i resolve this problem or Mapping the new version Parent-child relation  correctly?thks!!</p>