# Parent/child or nested mapping?

**URL:** <https://discuss.elastic.co/t/parent-child-or-nested-mapping/6582>\
**Category:** Elasticsearch\
**Created:** [February 3, 2012, 1:28pm UTC](https://discuss.elastic.co/t/parent-child-or-nested-mapping/6582 "2012-02-03T13:28:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Greg](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Greg](https://discuss.elastic.co/u/Greg)\
**Post date:** [February 3, 2012, 1:28pm UTC](https://discuss.elastic.co/t/parent-child-or-nested-mapping/6582/1 "2012-02-03T13:28:15Z")

</div>

Hi all

The JSON documents that I am indexing are of the following format:

"user" : {  
"name" : "Me",  
"email" : "me@example.com",  
"articles" : [  
{  
"title" : "Title 1",  
"body" : "Body 1",  
"tags" : ["tag1", "tag2"]  
},  
{  
"title" : "Title 2",  
"body" : "Body 2"  
"tags" : ["tag2", "tag3"]  
}  
]  
}

Each user has one or more articles. I predominantly need to search for  
articles across all users, e.g. all articles with a tag of 'tag2'.

My questions are as follows:

1. What is the difference between a parent/child and nested mapping?

2. Is it generally acceptable to organise this information into a  
nested JSON document, or is there a better way to define the  
relationship between users and articles?

Many thanks

Greg

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [February 5, 2012, 11:59am UTC](https://discuss.elastic.co/t/parent-child-or-nested-mapping/6582/2 "2012-02-05T11:59:42Z")

</div>

What search results to you expect to get? Is it articles that match your query or users?

On Friday, February 3, 2012 at 3:28 PM, Greg wrote:

> Hi all
> 
> The JSON documents that I am indexing are of the following format:
> 
> "user" : {  
> "name" : "Me",  
> "email" : "[me@example.com](mailto:me@example.com) ([mailto:me@example.com](mailto:me@example.com))",  
> "articles" : [  
> {  
> "title" : "Title 1",  
> "body" : "Body 1",  
> "tags" : ["tag1", "tag2"]  
> },  
> {  
> "title" : "Title 2",  
> "body" : "Body 2"  
> "tags" : ["tag2", "tag3"]  
> }  
> ]  
> }
> 
> Each user has one or more articles. I predominantly need to search for  
> articles across all users, e.g. all articles with a tag of 'tag2'.
> 
> My questions are as follows:
> 
> 1. What is the difference between a parent/child and nested mapping?
> 
> 2. Is it generally acceptable to organise this information into a  
> nested JSON document, or is there a better way to define the  
> relationship between users and articles?
> 
> Many thanks
> 
> Greg

---

<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, 3:40am UTC](https://discuss.elastic.co/t/parent-child-or-nested-mapping/6582/3 "2017-07-06T03:40:35Z")

</div>


