elasticsearch-dsl-py
elasticsearch-dsl-py copied to clipboard
`Document.update` doesn't allow updates with `InnerDoc`
For example:
class Location(InnerDoc):
country = Text()
city = Text()
class User(Document):
name = Text()
location = Object(Location)
class Index:
...
user = User(name='alice', location=Location(country='foo', city='bar'))
user.save()
user.update(location=Location(city='baz'))
then it will raise the following error
InnerDoc
inherits from AttrDict
, and merge
method accepts AttrDict
to be merged, the problem is that not all AttrDict
subclasses implement a dict-like interface for iterate, such as InnerDoc
I think, its better to first convert AttrDict
to dict in merge
method to make it iterable. After this fix, doc creation & update can both accept InnerDoc
.