ElasticSearch nested objects - get unique fields with thier respected values

We are a bit confused on how to store the following data to retrieve it later with ease. We will have a million records, of following type :

{
"width" : 720
"height" : 200
"coords" : [{
"el" : "xyz",
"x-y" : "100-50"
},
{
"el" : "abc",
"x-y" : "200-150"
}]
},
{
"width" : 1280
"height" : 1000
"coords" : [{
"el" : "lmn",
"x-y" : "400-50"
},
{
"el" : "abc",
"x-y" : "500-250"
}]
}

What type of aggregation query we will need to run to get the data in following form. As of now, i could only search for queries which return unique values with thier respective count (no. of occurances).

{
"el" : "xyz",
"x-y" : ["100-50"]
},
{
"el" : "abc",
"x-y" : ["200-150","500-250"]
},
{
"el" : "lmn",
"x-y" : ["400-50"]
}

We have created a mapping, where "coords" is of type nested. We can still change the mapping to get the better performance and results as we are still in development phase.

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