# Join in elasticsearch

**URL:** https://discuss.elastic.co/t/join-in-elasticsearch/10186
**Category:** Elasticsearch
**Created:** [December 27, 2012, 11:10pm UTC](https://discuss.elastic.co/t/join-in-elasticsearch/10186 "2012-12-27T23:10:32Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Fadel\_Chafai](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fadel_chafai/32/1105_2.png) [@Fadel\_Chafai](https://discuss.elastic.co/u/Fadel_Chafai)
#### Post date: [December 27, 2012, 11:10pm UTC](https://discuss.elastic.co/t/join-in-elasticsearch/10186/1 "2012-12-27T23:10:32Z")

</div>

Hi,

in my index i have two types Ads ans Product,

Product :

- \_index: fadel
- \_type: product
- \_id: 103|2
- \_version: 1
- \_score: 1
- \_source: {
  - code: 35569058
  - manufacturer: Packard Bell
  - tax\_class\_id: []
  - visibility: 4
  - price: []
  - in\_stock: 1
  - .....
  - ....

Ads

- \_index: fadel
- \_type: ads
- \_id: 92
- \_version: 1
- \_score: 1
- \_source: {
  - customer\_id: 2
  - ads\_id: 92
  - product\_id: 28
  - price\_current: 1200.0000
  - is\_pro\_customer: 0
  - state: 13
  - qty\_current: 19  
}

- fields: {
  - \_parent: 28|2  
}

so how can i get all ads for a product, and how I can retrieve the  
associated product to an ad

PS : 1 product may have one or more ads, but an ad associated to 1 product

thank you

--

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [December 28, 2012, 9:28am UTC](https://discuss.elastic.co/t/join-in-elasticsearch/10186/2 "2012-12-28T09:28:54Z")

</div>

For information, the same thread is opened on the french ml  
[https://groups.google.com/d/topic/elasticsearch-fr/N7zxurhUKjI/discussion](https://groups.google.com/d/topic/elasticsearch-fr/N7zxurhUKjI/discussion) .

David

Le 28 décembre 2012 à 00:10, Fadel Chafai [fadelmohamed@gmail.com](mailto:fadelmohamed@gmail.com) a écrit :

> Hi,
> 
> in my index i have two types Ads ans Product,
> 
> Product :
> 
> ```
> * _index: fadel
> * _type: product
> * _id: 103|2
> * _version: 1
> * _score: 1
> * _source: {
> o code: 35569058
> o manufacturer: Packard Bell
> o tax_class_id: []
> o visibility: 4
> o price: []
> o in_stock: 1
> o .....
> o ....
> 
> ```
> 
> Ads
> 
> ```
> * _index: fadel
> * _type: ads
> * _id: 92
> * _version: 1
> * _score: 1
> * _source: {
> o customer_id: 2
> o ads_id: 92
> o product_id: 28
> o price_current: 1200.0000
> o is_pro_customer: 0
> o state: 13
> o qty_current: 19
> }
> * fields: {
> o _parent: 28|2
> }
> 
> ```
> 
> so how can i get all ads for a product, and how I can retrieve the  
> associated product to an ad
> 
> PS : 1 product may have one or more ads, but an ad associated to 1 product
> 
> thank you
> 
> --

--  
David Pilato  
[http://www.scrutmydocs.org/](http://www.scrutmydocs.org/)  
[http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

---

<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/join-in-elasticsearch/10186/3 "2017-07-06T02:58:19Z")

</div>


