# Can't index data with parent/child mapping for Elasticsearch?

**URL:** https://discuss.elastic.co/t/cant-index-data-with-parent-child-mapping-for-elasticsearch/10150
**Category:** Elasticsearch
**Created:** [December 21, 2012, 10:27am UTC](https://discuss.elastic.co/t/cant-index-data-with-parent-child-mapping-for-elasticsearch/10150 "2012-12-21T10:27:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Jonathan\_Moo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonathan_moo/32/2562_2.png) [@Jonathan\_Moo](https://discuss.elastic.co/u/Jonathan_Moo)
#### Post date: [December 21, 2012, 10:27am UTC](https://discuss.elastic.co/t/cant-index-data-with-parent-child-mapping-for-elasticsearch/10150/1 "2012-12-21T10:27:14Z")

</div>

I tried to use the following mapping to index my data:

{  
"mappings": {  
"chow-demo": {  
"properties": {  
"@fields": {  
"dynamic": "true",  
"properties": {  
"asgid": {  
"type": "string",  
"analyzer": "keyword"  
},  
"asid": {  
"type": "long"  
},  
"astid": {  
"type": "long"  
},  
"clfg": {  
"analyzer": "keyword",  
"type": "string"  
},  
"httpcode": {  
"type": "long"  
},  
"oid": {  
"type": "string"  
},  
"onid": {  
"type": "long"  
},  
"ptrnr": {  
"analyzer": "keyword",  
"type": "string"  
},  
"pguid": {  
"analyzer": "keyword",  
"type": "string"  
},  
"ptid": {  
"type": "long"  
},  
"sid": {  
"type": "long"  
},  
"src\_url": {  
"analyzer": "keyword",  
"type": "string"  
},  
"title": {  
"analyzer": "keyword",  
"type": "string"  
},  
"ts": {  
"type": "long"  
}  
}  
},  
"@timestamp": {  
"format": "dateOptionalTime",  
"type": "date"  
},  
"@message": {  
"type": "string"  
},  
"@source": {  
"type": "string"  
},  
"@type": {  
"analyzer": "keyword",  
"type": "string"  
},  
"@tags": {  
"type": "string"  
},  
"@source\_host": {  
"type": "string"  
},  
"@source\_path": {  
"type": "string"  
}  
}  
},  
"chow-clfg": {  
"\_parent": {  
"type": "chow-demo"  
},  
"dynamic": "true",  
"properties": {  
"\_ttl": {  
"enabled": true,  
"default": "1h"  
},  
"clfg": {  
"analyzer": "keyword",  
"type": "string"  
},  
"@timestamp": {  
"format": "dateOptionalTime",  
"type": "date"  
},  
"count": {  
"type": "long"  
}  
}  
}  
}  
}

I tried to populate the parent type "chow-demo" without populating the  
child type "chow-clfg", and the document refused to index. (No documents  
were indexed into Elasticsearach)

When I take out the child mapping for "chow-clfg", it does indexing  
properly as usual. Hence I have the following question:

1. Is my mapping structure wrong?
2. Must the parent and child be indexed together at the same time before  
the data can be successfully indexed?

Really need help in this question for my project to progress! Thanks!

--

---

<div class="post-metadata">

### Author: ![Jonathan\_Moo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonathan_moo/32/2562_2.png) [@Jonathan\_Moo](https://discuss.elastic.co/u/Jonathan_Moo)
#### Post date: [December 24, 2012, 7:55am UTC](https://discuss.elastic.co/t/cant-index-data-with-parent-child-mapping-for-elasticsearch/10150/2 "2012-12-24T07:55:00Z")

</div>

Answer is already given by Imotov at Stackoverflow.

> <https://stackoverflow.com/questions/13987030/how-to-build-a-parent-child-mapping-for-elasticsearch/13989414#13989414>

On Friday, 21 December 2012 18:27:14 UTC+8, Jonathan Moo wrote:

> I tried to use the following mapping to index my data:
> 
> {  
> "mappings": {  
> "chow-demo": {  
> "properties": {  
> "@fields": {  
> "dynamic": "true",  
> "properties": {  
> "asgid": {  
> "type": "string",  
> "analyzer": "keyword"  
> },  
> "asid": {  
> "type": "long"  
> },  
> "astid": {  
> "type": "long"  
> },  
> "clfg": {  
> "analyzer": "keyword",  
> "type": "string"  
> },  
> "httpcode": {  
> "type": "long"  
> },  
> "oid": {  
> "type": "string"  
> },  
> "onid": {  
> "type": "long"  
> },  
> "ptrnr": {  
> "analyzer": "keyword",  
> "type": "string"  
> },  
> "pguid": {  
> "analyzer": "keyword",  
> "type": "string"  
> },  
> "ptid": {  
> "type": "long"  
> },  
> "sid": {  
> "type": "long"  
> },  
> "src\_url": {  
> "analyzer": "keyword",  
> "type": "string"  
> },  
> "title": {  
> "analyzer": "keyword",  
> "type": "string"  
> },  
> "ts": {  
> "type": "long"  
> }  
> }  
> },  
> "@timestamp": {  
> "format": "dateOptionalTime",  
> "type": "date"  
> },  
> "@message": {  
> "type": "string"  
> },  
> "@source": {  
> "type": "string"  
> },  
> "@type": {  
> "analyzer": "keyword",  
> "type": "string"  
> },  
> "@tags": {  
> "type": "string"  
> },  
> "@source\_host": {  
> "type": "string"  
> },  
> "@source\_path": {  
> "type": "string"  
> }  
> }  
> },  
> "chow-clfg": {  
> "\_parent": {  
> "type": "chow-demo"  
> },  
> "dynamic": "true",  
> "properties": {  
> "\_ttl": {  
> "enabled": true,  
> "default": "1h"  
> },  
> "clfg": {  
> "analyzer": "keyword",  
> "type": "string"  
> },  
> "@timestamp": {  
> "format": "dateOptionalTime",  
> "type": "date"  
> },  
> "count": {  
> "type": "long"  
> }  
> }  
> }  
> }  
> }
> 
> I tried to populate the parent type "chow-demo" without populating the  
> child type "chow-clfg", and the document refused to index. (No documents  
> were indexed into Elasticsearach)
> 
> When I take out the child mapping for "chow-clfg", it does indexing  
> properly as usual. Hence I have the following question:
> 
> 1. Is my mapping structure wrong?
> 2. Must the parent and child be indexed together at the same time  
> before the data can be successfully indexed?
> 
> Really need help in this question for my project to progress! 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 6, 2017, 2:58am UTC](https://discuss.elastic.co/t/cant-index-data-with-parent-child-mapping-for-elasticsearch/10150/3 "2017-07-06T02:58:36Z")

</div>


