# Unable to index child documents in parent-child relationship

**URL:** https://discuss.elastic.co/t/unable-to-index-child-documents-in-parent-child-relationship/37380
**Category:** Elasticsearch
**Created:** [December 16, 2015, 4:41pm UTC](https://discuss.elastic.co/t/unable-to-index-child-documents-in-parent-child-relationship/37380 "2015-12-16T16:41:22Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![godefroi](https://avatars.discourse-cdn.com/v4/letter/g/d78d45/32.png) [@godefroi](https://discuss.elastic.co/u/godefroi)
#### Post date: [December 16, 2015, 4:41pm UTC](https://discuss.elastic.co/t/unable-to-index-child-documents-in-parent-child-relationship/37380/1 "2015-12-16T16:41:22Z")

</div>

I've created an index with two types:

```
PUT /pc_test_index

{
  "mappings": {
    "childtype": {
      "_parent": {
        "type": "parenttype"
      },
      "properties": {
        "childprop": {
          "type": "string",
          "index": "not_analyzed"
        }
      }
    },
    "parenttype": {
      "properties": {
        "parentprop": {
          "type": "string",
          "index": "not_analyzed"
        }
      }
    }
  }
}

```

This went swimmingly. I can even index parent documents:

```
POST /pc_test_index/_bulk

{ "index": { "_id": "p01", "_type": "parenttype" } }
{ "parentprop": "parentprop01" }

```

What I cannot do, however, is index child documents:

```
POST /pc_test_index/_bulk

{ "index": { "_id": "c01", "_type": "childdtype", "parent": "p01" } }
{ "childprop": "childprop01" }

```

This results in an error:

```
{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "Can't specify parent if no parent field has been configured"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "Can't specify parent if no parent field has been configured"
  },
  "status": 400
}

```

This would, of course, make sense to me, except that I'm fairly certain that I configured the \_parent in the mapping for `childtype`. I have seen vague references to some type of `field` property in the `_parent` structure, but the documentation does not mention it (that I can find). Am I missing something obvious here?

Thanks for your time.

---

<div class="post-metadata">

### Author: ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)
#### Post date: [December 16, 2015, 5:51pm UTC](https://discuss.elastic.co/t/unable-to-index-child-documents-in-parent-child-relationship/37380/2 "2015-12-16T17:51:11Z")

</div>

> [@godefroi](#):
>
> { "index": { "\_id": "c01", "\_type": "childdtype", "parent": "p01" } }

You have a typo in your request: 'chliddtype' should be 'childtype'.

---

<div class="post-metadata">

### Author: ![godefroi](https://avatars.discourse-cdn.com/v4/letter/g/d78d45/32.png) [@godefroi](https://discuss.elastic.co/u/godefroi)
#### Post date: [December 16, 2015, 6:05pm UTC](https://discuss.elastic.co/t/unable-to-index-child-documents-in-parent-child-relationship/37380/3 "2015-12-16T18:05:10Z")

</div>

Indeed. How embarrassing. Works like a charm when I type correctly. Thanks!

---

<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: [July 5, 2017, 11:30pm UTC](https://discuss.elastic.co/t/unable-to-index-child-documents-in-parent-child-relationship/37380/4 "2017-07-05T23:30:29Z")

</div>


