Cross query

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.

I'm not sure I'm going to write anything better than this part of The Definitive Guide.

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...

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}
}

?