Search code examples
pythongoogle-app-engineexpando

Automatic indexes for expando properties in the google app engine for python


The google app engine python sdk offers an Expando type object which can be used for adding dynamic properties to an object that can be persisted to the datastore.

The app engine also requires that for any property on which the objects need to be searched or sorted, an index must be created before uploading the app to google's servers. This is really strange because it means that i am supposed to know before hand what properties my users will create on my objects. If i knew that in advance, why would i not define them as static properties in my existing model?

Does anyone know how to automatically create indexes for dynamic properties of Expando models after uploading to the app engine? If not, can anyone tell me why does the gae tout Expando as dynamic construct when it can not let you create new properties that can be searched on or sorted by, only properties that arent searchable or sortable.


Solution

  • All properties are automatically indexed for simple queries. Simple queries, in this case, are those that either:

    1. Use only equality filters, with no sort orders or inequality filters.
    2. Have an inequality filter or sort order on a single field, with no other filters.

    If you want to do more complex queries - such as ones that mix inequality and equality filters, only then do you need to build a custom index.

    It's not possible to build custom indexes at runtime. If you want to use expandos, you need to make sure that you restrict the queries you execute to those that are satisfiable under one of the situations above.