Aggregation from multiple indicates


(Amir Salar Pourhasan) #1

Hi
I`m new in ES and I have an important question.

I have 2 collections in MongoDB "matches" and "countries" for example:

matches (collection)  :
{
    _id : 11111,
    name: "team1",
    game: "Cup1"
    country_id : 101
},
{
    _id: 2222,
    name: "team2",
    game: "Cup1"
    country_id: 102
}

and

countries (collection)   :
{
    _id:  101,
    name: 'UK'
},
{
     _id: 102,
     name: 'Spain'
}

And I store these date in ES same as my MongoDB. I create 2 indicate "matches" and "countries".
Finally, I want whole match data of "team1" in one single JSON like this:

{
    _id:   1111,
    game:  "Cup1"
    localTeam:  "team1",
    country:  {
       _id: 101,
       name: 'UK'
    }
 },
 {
    _id:   2222,
    game:  "Cup1"
    localTeam:  "team2",
    country:  {
       _id: 102,
       name: 'UK'
    }
}

How can I do that? Basically, is my strategy a good one? What is the best practice?


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.