# Get error when indexing parent / child nodes in ElasticSearch.Net

**URL:** <https://discuss.elastic.co/t/get-error-when-indexing-parent-child-nodes-in-elasticsearch-net/203218>\
**Category:** Elasticsearch\
**Created:** [October 11, 2019, 11:03am UTC](https://discuss.elastic.co/t/get-error-when-indexing-parent-child-nodes-in-elasticsearch-net/203218 "2019-10-11T11:03:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steztric](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steztric/32/54873_2.png) [@Steztric](https://discuss.elastic.co/u/Steztric)\
**Post date:** [October 11, 2019, 11:03am UTC](https://discuss.elastic.co/t/get-error-when-indexing-parent-child-nodes-in-elasticsearch-net/203218/1 "2019-10-11T11:03:52Z")

</div>

Hi! I am trying to follow this tutorial on creating parent-child relationships between items;

[https://www.elastic.co/guide/en/elasticsearch/client/net-api/master/parent-child-relationships.html](https://www.elastic.co/guide/en/elasticsearch/client/net-api/master/parent-child-relationships.html)

My use-case is slightly different because in the tutorial you are creating a parent relationship between items in the same index. I want to create one between two different types of object, which need to be stored in different indexes. I came up with something like this;

```auto
class MyParentType
{
	public int Id {get;set;}
	public string Data {get;set;}
	public JoinField MyJoinField { get; } = typeof(MyParentType);
}

class MyChildType
{
	public int Id {get;set;}
	public string Data {get;set;}
	public JoinField ParentJoinField { get; set; }
	
    public MyChildType(MyParentType parent)
    {
        ParentJoinField = JoinField.Link<MyChildType, MyParentType>(parent);
    }
}

public static void Main(string[] args)
{
	var connectionSettings = new ConnectionSettings(
			pool, (builtin, settings) => new JsonNetSerializer(builtin, settings,
				() => new JsonSerializerSettings { Converters = { new StringEnumConverter() } }))
		.DefaultMappingFor<MyParentType>(m => m.IndexName("parents_index"))
		.DefaultMappingFor<MyChildType>(m => m.IndexName("children_index").RelationName("parents"));
		
	var client = new ElasticClient(connectionSettings);
	
	client.CreateIndex("parents_index", c => c
		.Index<MyParentType>()
		.Mappings(m => m.Map<MyParentType>(n => n
			.RoutingField(r => r.Required())
			.AutoMap<MyParentType>())));

	client.CreateIndex("children_index", c => c
		.Mappings(m => m.Map<MyChildType>(n => n
			.RoutingField(r => r.Required())
			.AutoMap<MyChildType>()
			.Properties(props => props
				.Join(j => j
					.Name(l => l.ParentNoteJoinField)
					.Relations(r => r
						.Join<MyParentType, MyChildType>()))))));
	
	var descriptor = new BulkDescriptor();
	descriptor.IndexMany(GetSomeCollectionOfParents());
	var response = client.Bulk(descriptor);
}

```

However, the last line returns a failed response from Elasticsearch;

> operation[0]: index returned 400 \_index: parents\_index \_type: myparenttype \_id: xyz123 \_version: 0 error: Type: mapper\_parsing\_exception Reason: "object mapping for [myJoinField] tried to parse field [myJoinField] as object, but found a concrete value"

Could someone please point out what I am doing wrong?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 8, 2019, 11:03am UTC](https://discuss.elastic.co/t/get-error-when-indexing-parent-child-nodes-in-elasticsearch-net/203218/2 "2019-11-08T11:03:59Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
