I am trying to query the datastore for the top 100 users in terms of points scored, who have logged on in the past week (the date field).
List<User> users = ofy().load().type(User.class)
.filter("date >", date).order("date")
.order("-points").limit(100).list();
It seems to ignore the final ordering by points and returns the list sorted by date instead. If I remove the date filter and sort then I get list nicely sorted by points, but including users who have logged on more than a week ago.
I have read the documentation carefully and it seems to allow queries that include both an inequality filter and multiple sorts.
Any ideas what I am doing wrong?
Here are some relevant notes from the documentation:
Because of the way the App Engine Datastore executes queries, if a query specifies inequality filters on a property and sort orders on other properties, the property used in the inequality filters must be ordered before the other properties.
... if a query specifies one or more inequality filters along with one or more sort orders, the first sort order must refer to the same property named in the inequality filters.