{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch-dsl-py/issues/833","repository_url":"https://api.github.com/repos/elastic/elasticsearch-dsl-py","labels_url":"https://api.github.com/repos/elastic/elasticsearch-dsl-py/issues/833/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch-dsl-py/issues/833/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch-dsl-py/issues/833/events","html_url":"https://github.com/elastic/elasticsearch-dsl-py/issues/833","id":294564414,"number":833,"title":"document id not added to HitMeta","user":{"login":"rholloway","id":3996981,"avatar_url":"https://avatars2.githubusercontent.com/u/3996981?v=4","gravatar_id":"","url":"https://api.github.com/users/rholloway","html_url":"https://github.com/rholloway","followers_url":"https://api.github.com/users/rholloway/followers","following_url":"https://api.github.com/users/rholloway/following{/other_user}","gists_url":"https://api.github.com/users/rholloway/gists{/gist_id}","starred_url":"https://api.github.com/users/rholloway/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rholloway/subscriptions","organizations_url":"https://api.github.com/users/rholloway/orgs","repos_url":"https://api.github.com/users/rholloway/repos","events_url":"https://api.github.com/users/rholloway/events{/privacy}","received_events_url":"https://api.github.com/users/rholloway/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-05T22:26:00Z","updated_at":"2018-02-05T22:27:54Z","closed_at":"2018-02-05T22:27:54Z","author_association":"NONE","body":"I've hit an issue that is unexpected to me and am not sure if I'm doing it wrong or if it's a bug.\r\n\r\nI have a class that overrides __init__ on doc type and handles some logic. When I'm querying for hits either using .get or .search, all results and objects come back how I think they should, but the meta.id field is missing.\r\n\r\nA (maybe overly simplified) example:\r\n\r\n```\r\nclass MyClass(DocType):\r\n  my_id = Keyword()\r\n  some_field = Boolean()\r\n\r\n  class Meta:\r\n    index = \"my-index\"\r\n\r\n  def __init__(self, meta=None, **kwargs):\r\n    super(MyClass, self).__init__(**kwargs)\r\n    some_field = True\r\n    self.more_custom_validation()\r\n\r\n  def more_custom_validation(self):\r\n    pass\r\n\r\n  def save(self, **kwargs):\r\n    self.my_id = str(uuid.uuid1()\r\n    self.meta.id = self.my_id\r\n    return super(MyClass, self).save(**kwargs)\r\n```\r\n\r\n```\r\n> a = MyClass()\r\n> a.some_field . # True, works\r\n> a.save()\r\n> a.meta.id  # a.meta.id == a.my_id, works\r\n> b = MyClass.get(a.meta.id)\r\n> b.meta # {'index': 'my-index'} . <-- note id isn't available here\r\n> b.update(some_field=False) . # cannot do without manually setting b.meta.id\r\n```"},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch-dsl-py/issues/comments/363242962","html_url":"https://github.com/elastic/elasticsearch-dsl-py/issues/833#issuecomment-363242962","issue_url":"https://api.github.com/repos/elastic/elasticsearch-dsl-py/issues/833","id":363242962,"user":{"login":"HonzaKral","id":32132,"avatar_url":"https://avatars0.githubusercontent.com/u/32132?v=4","gravatar_id":"","url":"https://api.github.com/users/HonzaKral","html_url":"https://github.com/HonzaKral","followers_url":"https://api.github.com/users/HonzaKral/followers","following_url":"https://api.github.com/users/HonzaKral/following{/other_user}","gists_url":"https://api.github.com/users/HonzaKral/gists{/gist_id}","starred_url":"https://api.github.com/users/HonzaKral/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HonzaKral/subscriptions","organizations_url":"https://api.github.com/users/HonzaKral/orgs","repos_url":"https://api.github.com/users/HonzaKral/repos","events_url":"https://api.github.com/users/HonzaKral/events{/privacy}","received_events_url":"https://api.github.com/users/HonzaKral/received_events","type":"User","site_admin":false},"created_at":"2018-02-05T22:27:54Z","updated_at":"2018-02-05T22:27:54Z","author_association":"MEMBER","body":"You are not passing the `meta` to `super(MyClass, self).__init__` so it gets dropped, you need to pass through all the atributes: `super(MyClass, self).__init__(meta=meta, **kwargs)`\r\n\r\nHope this helps!"}}
{"actor":{"display_login":"HonzaKral"}}