Skip to content

Commit dd5e5f2

Browse files
honzakral0bsearch
authored andcommitted
Allow users to redefine doc_type name in class Index
Fixes elastic#929
1 parent 75dad73 commit dd5e5f2

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

docs/persistence.rst

+4
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ the index, its name, settings and other attributes:
308308
used for any write operations and an ``index`` kwarg will have to be passed
309309
explicitly when calling methods like ``.save()``.
310310

311+
``doc_type``
312+
name of the ``_type`` in elasticsearch. Note that you have to define this as
313+
well as ``doc_type`` in ``class Meta`` in order for it to take effect.
314+
311315
``using``
312316
default connection alias to use, defaults to ``'default'``
313317

elasticsearch_dsl/document.py

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def construct_index(cls, opts, bases):
4242

4343
i = Index(
4444
getattr(opts, 'name', '*'),
45+
doc_type=getattr(opts, 'doc_type', 'doc'),
4546
using=getattr(opts, 'using', 'default')
4647
)
4748
i.settings(**getattr(opts, 'settings', {}))

0 commit comments

Comments
 (0)