Google App Engine - NDB - INDEX Quesions
google-app-engine, python-2.7
Solution
By default, the properties that can be indexed (i.e. those that aren't variants of Blob) are indexed, which means you can filter or sort by them on their own. Adding single-property indexes to index.yaml would be unusual. Setting indexed=False for a property will mean fewer write-operations when saving entities, but will mean filtering or sorting by the property is no longer possible. I'd suggest reading the documentation on indexes.
If you want to filter or sort (in combination) by more than one property, then you need to include them in index.yaml. However, as you run code in the development server, if it requires an index that hasn't yet been specified, then index.yaml will be modified to contain a suitable index for the query being run. Adding indexes manually isn't necessarily something you'll ever have to do.
You can't index an entire StructuredProperty, the properties of Structured Properties are individually indexed, and don't need to think about them any differently than for regular properties. If you want to manually specify a multi-property index that includes a sub-property, then you should be able to do so by using 'property.subproperty' (e.g. 'address.city').
Problem
I had the following question about GAE NDB - Index. - I assume you can specify index via `index.yaml` or within the model definition using property option, `indexed = true`. Am I correct? If yes is one preferred over the other? - Is there a way to add/drop index during the life cycle of the data objects? - Can I specify an index on a structured property field? If so, then can you please let me know** as the syntax for this? Thanks in advance