Why does elasticsearch-dsl-py raise an exception on pypy but not cpython?

(Sean Whalen) #1

I have some code that saves data to Elasticsearch. It runs fine in Python 3.5.2 (cpython), but raises an exception when running on pypi3 6.0.0 (Python 3.5.3). Any ideas why?

File "/opt/venvs/parsedmarc/site-packages/parsedmarc/elastic.py", line 366, in save_forensic_report_to_elasticsearch
File "/opt/venvs/parsedmarc/site-packages/elasticsearch_dsl/document.py", line 394, in save
File "/opt/venvs/parsedmarc/site-packages/elasticsearch_dsl/document.py", line 138, in _get_index
  raise ValidationException('You cannot write to a wildcard index.')
elasticsearch_dsl.exceptions.ValidationException: You cannot write to a wildcard index

Looking at document.py, that exception is only supposed to be raised when a save attempt is made on an index name that contains *.

I set the index name using a Meta class as as you can see here, and there is not any * in the index variable.

Here's some basic sample code to reproduce the issue:

Note: you must have an Elasticsearch instance running to reproduce the issue.

from elasticsearch_dsl import DocType, Text, connections

class _ForensicReportDoc(DocType):
    class Meta:
        index = "sample_index"

    feedback_type = Text()

connections.create_connection(hosts=[""], timeout=20)

doc = _ForensicReportDoc(feedback_type="foo")

(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.