Skip to content

Index.document() doesn't set index on Document on elasticsearch-dsl-py>=6.3.0 #1091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sir-sigurd opened this issue Dec 13, 2018 · 0 comments

Comments

@sir-sigurd
Copy link

This code worked on elasticsearch-dsl-py==6.2.1

from elasticsearch_dsl import Index, Document, Text

i = Index('blog')

@i.document
class Post(Document):
    title = Text()

Post().to_dict(include_meta=True)

But on elasticsearch-dsl-py>=6.3.0 error is raised:

ValidationException                       Traceback (most recent call last)
<ipython-input-11-0a92233a929e> in <module>
      7     title = Text()
      8
----> 9 Post().to_dict(include_meta=True)

/usr/local/lib/python3.6/site-packages/elasticsearch_dsl/document.py in to_dict(self, include_meta, skip_empty)                                                                                                     
    309
    310         # in case of to_dict include the index unlike save/update/delete
--> 311         index = self._get_index(required=False)
    312         if index is not None:
    313             meta['_index'] = index

/usr/local/lib/python3.6/site-packages/elasticsearch_dsl/document.py in _get_index(self, index, required)
    146             raise ValidationException('No index')
    147         if index and '*' in index:
--> 148             raise ValidationException('You cannot write to a wildcard index.')
    149         return index
    150

ValidationException: You cannot write to a wildcard index.

Index.document() is documented here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant