Sweet! Thank you. I’ve been on GAE since the beginning, and I guess you added that at some point after I stopped reading the documentation ;)
> On Feb 24, 2016, at 10:02 AM, 'Alex Martelli' via Google App Engine > <[email protected]> wrote: > > > > On Wed, Feb 24, 2016 at 6:51 AM, Joshua Smith <[email protected] > <mailto:[email protected]>> wrote: > I just wrote a new app and it has an entity that I use to show a leader board: > > class CountModel(db.Model): > count = db.IntegerProperty(default=0) > trend = db.FloatProperty(default=0.0) > > I get the list of these using a simple query: > > if self.request.get("mode") == "trend": > counts = CountModel.gql("ORDER BY trend DESC").fetch(20) > else: > counts = CountModel.gql("ORDER BY count DESC").fetch(20) > > I ran this in my dev environment and then checked index.yaml to make sure it > made the indexes. It didn’t. > > So I pushed it to production, fully expecting to see an error when I ran the > query because I didn’t have this index defined. No error. > > It works perfectly. > > I also have this query in a cron job, and it works fine without the index, > too: > > for c in CountModel.gql("WHERE trend > 1"): > > Has something changed? It used to be that to do an ordered query, or an > inequality query, you had to have an index. > > You still do, but single-property indices are generated automatically. That's > documented at > https://cloud.google.com/appengine/docs/python/datastore/indexes > <https://cloud.google.com/appengine/docs/python/datastore/indexes> : "App > Engine predefines a simple index on each property of an entity. An App Engine > application can define further custom indexes". > > and later in the same page, to clarify: > > The Datastore builds automatic indexes for queries of the following forms: > > Kindless queries using only ancestor and key filters > Queries using only ancestor and equality filters > Queries using only inequality filters (which are limited to a single > property) > > etc. Your use case falls within the third one of these. > > > Alex > > > -Joshua > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:google-appengine%[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > Visit this group at https://groups.google.com/group/google-appengine > <https://groups.google.com/group/google-appengine>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-appengine/38ED761B-EEBE-4CED-80B6-ADF42357BF57%40gmail.com > > <https://groups.google.com/d/msgid/google-appengine/38ED761B-EEBE-4CED-80B6-ADF42357BF57%40gmail.com>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. > > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > Visit this group at https://groups.google.com/group/google-appengine > <https://groups.google.com/group/google-appengine>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-appengine/CAE46Be8aGB_ant9yav0dqWkuaVQkM8o1X96H_hwyXz2qRo8TFg%40mail.gmail.com > > <https://groups.google.com/d/msgid/google-appengine/CAE46Be8aGB_ant9yav0dqWkuaVQkM8o1X96H_hwyXz2qRo8TFg%40mail.gmail.com?utm_medium=email&utm_source=footer>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/google-appengine. To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/53084996-1FA7-4D74-9772-0C38B31F5394%40gmail.com. For more options, visit https://groups.google.com/d/optout.
