Skip to content
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

TypeError when fetching a mapping #475

Open
dduong42 opened this issue Dec 22, 2014 · 0 comments
Open

TypeError when fetching a mapping #475

dduong42 opened this issue Dec 22, 2014 · 0 comments

Comments

@dduong42
Copy link

Environment: Python 3

When fetching for a mapping I got this error:

In [1]: import pyes

In [2]: es = pyes.es.ES()

In [3]: data = es.indices.get_mapping(doc_type='category', indices='catalog')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-7fea737910c0> in <module>()
----> 1 data = es.indices.get_mapping(doc_type='category', indices='catalog')

/home/daniel/.envs/oshop/lib/python3.4/site-packages/pyes/managers.py in get_mapping(self, doc_type, indices, raw)
    453         mapper = Mapper(result, is_mapping=False,
    454                         connection=self.conn,
--> 455                         document_object_field=self.conn.document_object_field)
    456         if doc_type:
    457             return mapper.mappings[doc_type]

/home/daniel/.envs/oshop/lib/python3.4/site-packages/pyes/mappings.py in __init__(self, data, connection, is_mapping, document_object_field)
    825         self.full_mappings = False
    826         self.document_object_field = document_object_field
--> 827         self._process(data)
    828 
    829     def _process(self, data):

/home/daniel/.envs/oshop/lib/python3.4/site-packages/pyes/mappings.py in _process(self, data)
    835             idata = []
    836             for docname, docdata in list(indexdata.get("mappings", {}).items()):
--> 837                 o = get_field(docname, docdata, document_object_field=self.document_object_field, is_document=True)
    838                 o.connection = self.connection
    839                 o.index_name = indexname

/home/daniel/.envs/oshop/lib/python3.4/site-packages/pyes/mappings.py in get_field(name, data, default, document_object_field, is_document)
    793         else:
    794             data.pop("name",None)
--> 795             return DocumentObjectField(name=name, **data)
    796 
    797     elif _type == "object":

TypeError: __init__() keywords must be strings

After some investigation, the problem comes from this line, converting the keys of the data dictionary into byte objects:

data = keys_to_string(data)
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

No branches or pull requests

1 participant