How to get the combined data from two different document?


(narinder.izap) #1

Hi there,

I have a situation where i need to apply some kind of join in the query,
like fetching some data from one document and some from other based on some
common attribute value. As for example the two documents are:
type :user

title:"abc",
id:"1",
city:"aaa",
DOB:"10-10-90",
fan_id:"10"

and the second document will be
type : relation
*
*
*
*
fan_of :"10",
"time_created":"398769978"

now i have to get the users from document type:user whose fan_of = fan_id
and sort the documents by second document 's time_created. Can anyone help
me??


(Karussell) #2

Maybe top_children query could help:

http://www.elasticsearch.org/guide/reference/query-dsl/top-children-query.html

Peter.

On Nov 7, 1:14 pm, Narinder Kaur narinder.k...@izap.in wrote:

Hi there,

I have a situation where i need to apply some kind of join in the query,
like fetching some data from one document and some from other based on some
common attribute value. As for example the two documents are:
type :user

title:"abc",
id:"1",
city:"aaa",
DOB:"10-10-90",
fan_id:"10"

and the second document will be
type : relation
*
*
*
*
fan_of :"10",
"time_created":"398769978"

now i have to get the users from document type:user whose fan_of = fan_id
and sort the documents by second document 's time_created. Can anyone help
me??


(system) #3