# Cross query

**URL:** <https://discuss.elastic.co/t/cross-query/32472>\
**Category:** Elasticsearch\
**Created:** [October 19, 2015, 10:10am UTC](https://discuss.elastic.co/t/cross-query/32472 "2015-10-19T10:10:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kodermax](https://avatars.discourse-cdn.com/v4/letter/k/9d8465/32.png) [@kodermax](https://discuss.elastic.co/u/kodermax)\
**Post date:** [October 19, 2015, 10:10am UTC](https://discuss.elastic.co/t/cross-query/32472/1 "2015-10-19T10:10:54Z")

</div>

I have two types  
deals and contacts.  
deals: {  
'title': 'deal1',  
'contact\_id': 234  
}  
contacts: {  
'id': 234,  
'title': 'sad'  
}

How can i get deals by contact filter.  
I'd like to get deals of contact Sad.

---

<div class="post-metadata">

**Author:** ![softwaredoug](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/softwaredoug/32/22681_2.png) [@softwaredoug](https://discuss.elastic.co/u/softwaredoug)\
**Post date:** [October 19, 2015, 1:24pm UTC](https://discuss.elastic.co/t/cross-query/32472/2 "2015-10-19T13:24:32Z")

</div>

I'm not sure I'm going to write anything better than [this part of The Definitive Guide](https://www.elastic.co/guide/en/elasticsearch/guide/current/relations.html).

Basically, the search engine is going to work best if you can denormalize your data (make contacts a child of deals or vice versa). If that's not feasible and you're not able to do this, you can experiment with application side joins (feels icky to me). Also, don't throw out the RDMS if what you really need is to model relational data...

---

<div class="post-metadata">

**Author:** ![kodermax](https://avatars.discourse-cdn.com/v4/letter/k/9d8465/32.png) [@kodermax](https://discuss.elastic.co/u/kodermax)\
**Post date:** [October 19, 2015, 1:32pm UTC](https://discuss.elastic.co/t/cross-query/32472/3 "2015-10-19T13:32:10Z")

</div>

You mean

```
"contacts" : {
  "title": "sad",
    "deals": [61,43,65]
}

```

or

```
"deals": {
   "id" :123,
   "title": "test",
   "contact": {id:'34','title':"sad', 'email':'test@test.ru','phone':13213}
}

```

?

---

<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:44pm UTC](https://discuss.elastic.co/t/cross-query/32472/4 "2017-07-05T23:44:02Z")

</div>

Closed on July 5, 2017, 11:44pm UTC


