1
votes

I have an ndb.Model that contains an ndb.Expando model as a structured property, and I'd like to be able to control indexing, but I cannot find anything in the documentation about it.

class MyModel2(ndb.Expando):
    pass

class MyModel(ndb.Model):
    sub_entity = ndb.StructuredProperty(MyModel2)

The only piece of documentation I can find is the following:

You can specify the usual property options for structured properties (except indexed)

I assume this is because the actual indexing should be specified on a per-property basis in the embedded model. However, it is not clear how to enable or disable indexing on Expando model properties.

1

1 Answers

4
votes

You can use the _properties object to set if a field should be indexed or not. E.g.

a = MyModel2()
a.value = '3'
a._properties['value']._indexed = False

You can find the docs on _properties have more details.