# Nested mapping example

**URL:** <https://discuss.elastic.co/t/nested-mapping-example/11745>\
**Category:** Elasticsearch\
**Created:** [April 30, 2013, 8:53am UTC](https://discuss.elastic.co/t/nested-mapping-example/11745 "2013-04-30T08:53:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maarten\_Roosendaal](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@Maarten\_Roosendaal](https://discuss.elastic.co/u/Maarten_Roosendaal)\
**Post date:** [April 30, 2013, 8:53am UTC](https://discuss.elastic.co/t/nested-mapping-example/11745/1 "2013-04-30T08:53:22Z")

</div>

Hi,

I'm looking for a nested mapping and index example.What i want is to a have  
3 entities:

1. product [title, description, brand,etc]
2. offer [price, availability]
3. review [rating, reviewdescription]  
product has 1 or more offers  
product has 0 or more reviews

I'm just not sure how to relate these entities through mapping and how to  
index them. I assume you can index them seperatly but you would need a  
reference to a parent.

Hope someone can point me in the right direction.

Thanks,  
Maarten

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Andrej](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Andrej](https://discuss.elastic.co/u/Andrej)\
**Post date:** [April 30, 2013, 12:11pm UTC](https://discuss.elastic.co/t/nested-mapping-example/11745/2 "2013-04-30T12:11:33Z")

</div>

Hi,

from my understanding you cant index the nested objects separatly, that  
would be a parent/child relation, not a nested object. I found this useful:

> **[Fun with elasticsearch's children and nested documents - Space Vatican](https://www.spacevatican.org/2012/6/3/fun-with-elasticsearch-s-children-and-nested-documents/)**
>
> When you’re indexing data, the world is rarely as simple as each document existing in isolation. Sometimes, you’re better off …

Your mapping could look like this:

mappings: {  
product: {  
properties: {  
title: { type: string }  
description: { type: string }  
brand: { type: string }  
offer: {  
properties: {  
price: {  
type: float  
}  
availability: {  
type: whatever  
}  
}  
type: nested  
}  
review: {  
properties: {  
description: {  
type: string  
}  
rating: {  
type: float  
}  
}  
type: nested  
}  
}  
}  
}

Am Dienstag, 30. April 2013 10:53:22 UTC+2 schrieb Maarten Roosendaal:

> Hi,
> 
> I'm looking for a nested mapping and index example.What i want is to a  
> have 3 entities:
> 
> 1. product [title, description, brand,etc]
> 2. offer [price, availability]
> 3. review [rating, reviewdescription]  
> product has 1 or more offers  
> product has 0 or more reviews
> 
> I'm just not sure how to relate these entities through mapping and how to  
> index them. I assume you can index them seperatly but you would need a  
> reference to a parent.
> 
> Hope someone can point me in the right direction.
> 
> Thanks,  
> Maarten

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Maarten\_Roosendaal](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@Maarten\_Roosendaal](https://discuss.elastic.co/u/Maarten_Roosendaal)\
**Post date:** [May 1, 2013, 1:32pm UTC](https://discuss.elastic.co/t/nested-mapping-example/11745/3 "2013-05-01T13:32:51Z")

</div>

Thanks for the website, great link. I'll tr y and play with it.

Op dinsdag 30 april 2013 14:11:33 UTC+2 schreef Andrej Rosenheinrich het  
volgende:

> Hi,
> 
> from my understanding you cant index the nested objects separatly, that  
> would be a parent/child relation, not a nested object. I found this useful:  
> [Fun with elasticsearch's children and nested documents - Space Vatican](http://www.spacevatican.org/2012/6/3/fun-with-elasticsearch-s-children-and-nested-documents/)
> 
> Your mapping could look like this:
> 
> mappings: {  
> product: {  
> properties: {  
> title: { type: string }  
> description: { type: string }  
> brand: { type: string }  
> offer: {  
> properties: {  
> price: {  
> type: float  
> }  
> availability: {  
> type: whatever  
> }  
> }  
> type: nested  
> }  
> review: {  
> properties: {  
> description: {  
> type: string  
> }  
> rating: {  
> type: float  
> }  
> }  
> type: nested  
> }  
> }  
> }  
> }
> 
> Am Dienstag, 30. April 2013 10:53:22 UTC+2 schrieb Maarten Roosendaal:
> 
> > Hi,
> > 
> > I'm looking for a nested mapping and index example.What i want is to a  
> > have 3 entities:
> > 
> > 1. product [title, description, brand,etc]
> > 2. offer [price, availability]
> > 3. review [rating, reviewdescription]  
> > product has 1 or more offers  
> > product has 0 or more reviews
> > 
> > I'm just not sure how to relate these entities through mapping and how to  
> > index them. I assume you can index them seperatly but you would need a  
> > reference to a parent.
> > 
> > Hope someone can point me in the right direction.
> > 
> > Thanks,  
> > Maarten

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:38am UTC](https://discuss.elastic.co/t/nested-mapping-example/11745/4 "2017-07-06T02:38:50Z")

</div>


