I have a sharded dataset like the example below where every month a new shard is created with vote counts recorded on posts. (This isn't exactly the data I'm using but representative of the structure I need)
{
"votes" : {
"201604" : {
"First Post" : {
"count" : 1,
"label" : "First Post"
},
"Second Post" : {
"count" : 3,
"label" : "Second Post"
},
"Third Post" : {
"count" : 1,
"label" : "Third Post"
}
}
"201605" : {
"First Post" : {
"count" : 5,
"label" : "First Post"
},
"Second Post" : {
"count" : 3,
"label" : "Second Post"
},
"Third Post" : {
"count" : 2,
"label" : "Third Post"
}
}
}
}
What I need to do is return the top X Posts by Count for the last Y shards (descending)
This query doesn't work as I can't combine multiple orderBy clauses but in my mind is explaining what I'm trying to achieve;
database.child("votes").limitToLast(2).orderByValue().orderByChild("count").limitToFirst(10);