Joins using internal queries


(talsalmona) #1

Hi Shay,

Do you have plans to add support for "emulating" joins on
ElasticSearch?
What I mean is being able to define something like a script field that
would actually do an additional get to fetch a child document and
embed it in the result as if it was part of the parent doc.
I think this a very common scenario and I've seen some questions about
it in the forum.
Of course this could be done on the client side but I think it would
be nicer doing it inside ElasticSearch.

{
"query" : {
...
},
"script_fields" : {
"joined_doc" : {
"by_id" : {
"index": "other_index"
"type": "other_type"
"id": "doc['my_field_name'].value"
}
}
}
}

Thanks,
Tal


(Shay Banon) #2

Yea, I do have some ideas on how to implement it. Get is a good high level
view of how it might work, but its much different under the covers. Going to
play with my idea on how to solve it in the next couple of weeks, need to
validate it first....

-shay.banon

On Tue, Sep 28, 2010 at 11:40 PM, Tal talsalmona@gmail.com wrote:

Hi Shay,

Do you have plans to add support for "emulating" joins on
ElasticSearch?
What I mean is being able to define something like a script field that
would actually do an additional get to fetch a child document and
embed it in the result as if it was part of the parent doc.
I think this a very common scenario and I've seen some questions about
it in the forum.
Of course this could be done on the client side but I think it would
be nicer doing it inside ElasticSearch.

{
"query" : {
...
},
"script_fields" : {
"joined_doc" : {
"by_id" : {
"index": "other_index"
"type": "other_type"
"id": "doc['my_field_name'].value"
}
}
}
}

Thanks,
Tal


(system) #3