A beginner in ElasticSearch DSL here.
I have a list of users and their locations with location attributes as nested data.
{
"id" : "ojEggfh9GRs"
"name" : "chan k",
"locations" : [
{
"locationId" : "1010",
"orderCount" : 100
},
{
"locationId" : "1020",
"orderCount" : 50
},
{
"locationId" : "1030",
"orderCount" : 10
}
]
},
{....}
What I'd like to query is: The list of users with name match and who have certain locations given in query (match nested locationId), sorted by the sum of orderCount across those locations.
I tried a aggregation query for this, but i need user name and user id and few other attributes in results, it does not seem like correct way to do it.
Let me know if anyone can help me understand how can I get this result with other options like function-score or something else.