# Parent/Child relationship with NEST on 6.x

**URL:** <https://discuss.elastic.co/t/parent-child-relationship-with-nest-on-6-x/116497>\
**Category:** Elasticsearch\
**Created:** [January 22, 2018, 3:26pm UTC](https://discuss.elastic.co/t/parent-child-relationship-with-nest-on-6-x/116497 "2018-01-22T15:26:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carlo\_Arnaboldi](https://avatars.discourse-cdn.com/v4/letter/c/838e76/32.png) [@Carlo\_Arnaboldi](https://discuss.elastic.co/u/Carlo_Arnaboldi)\
**Post date:** [January 22, 2018, 3:26pm UTC](https://discuss.elastic.co/t/parent-child-relationship-with-nest-on-6-x/116497/1 "2018-01-22T15:26:28Z")

</div>

Greetings. I've been tasked to gain some basic knowledge with NEST / Elastic search to verify if this product suits our needs. I've a C# / Relational databases background.

I've installed Kibana (6.1.1) and Elastic search (6.1.1)

I've also created a VS2017 project with latests version of [elasticsearch.NET](http://elasticsearch.NET) (6.0.0-rc1) and NEST (6.0.0-rc1) with the idea to create 2 types which share a parent-child relation. After the types are created correctly, I'm planning to import some documents from 2 existing SQL tables which are in one-to-many relationship.

I've been following the guide at this page to do so (doing exactly what is stated):

[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)

**but several pieces of code are not compiling** , for instance:

```
var infer = client.Infer;
var parent = new MyParent {Id = 1337, MyJoinField = JoinField.Root<MyParent>()};
infer.Routing(parent).Should().Be("1337");

```

I'm unable to find the "Routing" member of the class "Inferrer" (object infer). It looks like I'm working with the wrong guide but I've been downloading the most recent NEST / [ElasticSearch.NET](http://ElasticSearch.NET) packets available on nuget (including prereleases) and I'm looking at the most recent NEST guide (I've selected "master" in the combobox to choose guide version).

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [January 23, 2018, 1:05am UTC](https://discuss.elastic.co/t/parent-child-relationship-with-nest-on-6-x/116497/2 "2018-01-23T01:05:08Z")

</div>

Hey @Carlo_Arnaboldi, the usage of `Infer` within the documentation is simply to assert that the routing value is what is expected; the documentation is generated from tests to ensure that it stays in line with the client.

In your code, you would simply index the `Parent` and `Child` documents, and there are a number of different ways that you can specify the join field.

For `Parent`

```auto
// 1. Use JoinField.Root<MyParent>()
var parentDocument = new MyParent
{
    Id = 1,
    ParentProperty = "a parent prop",
    MyJoinField = JoinField.Root<MyParent>()
};

// 2. Use typeof(MyParent)
parentDocument = new MyParent
{
    Id = 1,
    ParentProperty = "a parent prop",
    MyJoinField = typeof(MyParent) 
};

// 2. Use string
parentDocument = new MyParent
{
    Id = 1,
    ParentProperty = "a parent prop",
    MyJoinField = "myparent" 
};

var indexParentResponse = client.IndexDocument<MyDocument>(parentDocument);

```

and for `Child`

```auto
// 1. Use JoinField.Link<MyChild, MyParent>(parentDocument)
var childDocument = new MyChild
{
    MyJoinField = JoinField.Link<MyChild, MyParent>(parentDocument)
});

// 2. Use JoinField.Link<MyChild>(1)
childDocument = new MyChild
{
    Id = 2,
    MyJoinField = JoinField.Link<MyChild>(1)
});

indexChildResponse = client.IndexDocument<MyDocument>(childDocument );

```

---

<div class="post-metadata">

**Author:** ![Carlo\_Arnaboldi](https://avatars.discourse-cdn.com/v4/letter/c/838e76/32.png) [@Carlo\_Arnaboldi](https://discuss.elastic.co/u/Carlo_Arnaboldi)\
**Post date:** [February 6, 2018, 5:10pm UTC](https://discuss.elastic.co/t/parent-child-relationship-with-nest-on-6-x/116497/3 "2018-02-06T17:10:17Z")

</div>

Sorry for the late reply. Thanks for pointing that out. Anyway at the end we decided avoid ES joins since they are not supported in Kibana. We'll perform application-side joins in the event that we need to query ES outside of Kibana (with NEST, for example)

---

<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:** [March 6, 2018, 5:10pm UTC](https://discuss.elastic.co/t/parent-child-relationship-with-nest-on-6-x/116497/4 "2018-03-06T17:10:23Z")

</div>

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