I have not tried this myself, but the documentation states that sort orders
are ignored if you use an *Equality* filter and a sort order; you are using
inequality filters and a sort order.
On Friday, June 22, 2012 9:03:11 PM UTC-4, Waleed wrote:
>
> I have a model with a multi-valued property, "events", and I want to
> filter by a specific range of events and sort by them at the same time:
>
> class MyModel(db.Model):
> events = db.StringListProperty(indexed=True)
>
> print MyModel.all().filter("events >=", x).filter("events <=",
> y).order("events").fetch(100)
>
>
> I expect the results to be sorted by whichever value in the list
> property that matched the range condition (and that's how I understand the
> indexs to be organized). This seems to be working as expected in the SDK,
> and if I reverse the order ("-events") it returns the results in reverse as
> well, which is great.
>
> However, I'm concerned about the section below from the
> documentation<https://developers.google.com/appengine/docs/python/datastore/queries>
> which
> states that sort orders are ignored. It's not clear to me, though, if the
> sort order is ignored completely or ignored only for the "other" values in
> the property list that did not match the range condition. And if it is
> ignored, then how come reversing the sort oder in the code above also
> reversed the order of the results I get?
>
> Sort Orders Are Ignored on Properties with Equality Filters
>
> One important caveat is queries with both an equality filter and a sort
> order on a multi-valued property. In those queries, the sort order is
> disregarded. For single-valued properties, this is a simple optimization.
> Every result would have the same value for the property, so the results do
> not need to be sorted further.
>
> However, multi-valued properties may have additional values. Since the
> sort order is disregarded, the query results may be returned in a different
> order than if the sort order were applied. (Restoring the dropped sort
> order would be expensive and require extra indices, and this use case is
> rare, so the query planner leaves it off.)
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-appengine/-/acc0QQ9wAVIJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.