I have emails in the index which look like these:
{
"emailId" : 1,
"to" : "a@example.com",
"from" : "b@example.com",
"subject" : "xyz subject"
},
{
"emailId" : 2,
"to" : "b@example.com",
"from" : "c@example.com",
"subject" : "abc subject"
},
{
"emailId" : 3,
"to" : "c@example.com",
"from" : "d@example.com",
"subject" : "some subject"
},
{
"emailId" : 1,
"to" : "b@example.com",
"from" : "a@example.com",
"subject" : "xyz subject"
}
I would like to query the index to get a response to show on a chord diagram, which requires the data in this format:
[
{ from: "A", to: "D", value: 10 },
{ from: "B", to: "D", value: 8 },
{ from: "B", to: "E", value: 4 },
{ from: "B", to: "C", value: 2 },
{ from: "C", to: "E", value: 14 },
{ from: "E", to: "D", value: 8 },
{ from: "C", to: "A", value: 4 },
{ from: "G", to: "A", value: 7 },
{ from: "D", to: "B", value: 1 }
]
What's the best way to model the document and what aggregation would be the best?
Thanks!