Document mapping doesn't accept any name but 'doc'
See original GitHub issueI tried to use the new 6.2 release and found that the following code crashes:
from elasticsearch_dsl import Document, Mapping
class MyDoc(Document):
class Meta:
mapping = Mapping('a')
With the following trace:
/lib/python3.6/site-packages/elasticsearch_dsl/document.py in __new__(cls, name, bases, attrs)
30 new_cls = super(IndexMeta, cls).__new__(cls, name, bases, attrs)
31 new_cls._index = cls.construct_index(index_opts, bases)
---> 32 new_cls._index.document(new_cls)
33 return new_cls
34
/lib/python3.6/site-packages/elasticsearch_dsl/index.py in document(self, document)
121 raise IllegalOperation(
122 'Index object cannot have multiple types, %s already set, '
--> 123 'trying to assign %s.' % (self._mapping.doc_type, name))
124 self._doc_types.append(document)
125 # TODO: do this at save time to allow Document to be modified after
IllegalOperation: Index object cannot have multiple types, doc already set, trying to assign a.
I tried to add doc_type='a'
to the Meta
class, but it didn’t help. As far as I have tried, there’s absolutely no way to have a mapping which is not named 'doc'
. This is also incompatible with existing indexes.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (2 by maintainers)
Top Results From Across the Web
You receive error messages when opening an Office document
This issue occurs when you open a file from a mapped drive, a UNC path, ... Microsoft Excel: The total length of the...
Read more >Name Mapping | TestComplete Documentation
The Name Mapping repository stores all the objects of your tested applications that your automated tests use. For each object, the Name Mapping...
Read more >Error Messages | Maps JavaScript API - Google Developers
This page describes the error messages that can be returned by the Maps JavaScript API. The Maps JavaScript API writes error and warning...
Read more >Fine-grained access control in Amazon OpenSearch Service
The access policy accepts or rejects requests at the "edge" of the domain, ... You can't sign a request with a user name...
Read more >Guidelines for representing your business on Google
We also do not allow solicitation of the above information through local posts or a business description other than the user's own name,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you all for your patience, I just pushed a fix that should make the part in
class Index
optional, so just defining aclass Meta: doc_type = "a"
should be enough.I also cleaned up a lot of faulty logic when it came to
Index
handling. If you could test the currentmaster
(69f5ca2dc7657c26a19f11d75b7c2080afcfcdd6) I would be most grateful! After it has been tested I will release it as6.3.0
@rafaelcaricio, turns out I should have troubleshot a little longer 😄 …
The following worked for me to avoid
elasticsearch_dsl.exceptions.IllegalOperation
:I noticed that the following gave the error
a already set, trying to assign doc
And this gave the same error but reversed
doc already set, trying to assign a
So setting
doc_type
in bothIndex
andMeta
is required to align them and prevent the error.@HonzaKral do you know if this behavior is intentional?