Skip to content

Commit 2f637c5

Browse files
safwanrahmanhonzakral
authored andcommitted
set index name to None
1 parent c1da301 commit 2f637c5

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

elasticsearch_dsl/document.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def construct_index(cls, opts, bases):
5151
if hasattr(b, '_index'):
5252
return b._index
5353

54-
# return None as there are no index_opts
55-
return None
54+
# Set None as Index name so it will set _all while making the query
55+
return Index(name=None)
5656

5757
i = Index(
5858
getattr(opts, 'name', '*'),

elasticsearch_dsl/index.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,10 @@ class Post(Document):
160160
'trying to assign %s.' % (doc_type, name))
161161
self._doc_types.append(document)
162162

163-
# If the document does not have any index, set this index as document index
164-
if document._index is None:
163+
# If the document index does not have any name, that means the user
164+
# did not set any index already to the document.
165+
# So set this index as document index
166+
if document._index._name is None:
165167
document._index = self
166168

167169
return document

0 commit comments

Comments
 (0)