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

**URL:** <https://discuss.elastic.co/t/why-does-elasticsearch-dsl-py-raise-an-exception-on-pypy-but-not-cpython/140343>\
**Category:** Elasticsearch\
**Created:** [July 17, 2018, 2:22pm UTC](https://discuss.elastic.co/t/why-does-elasticsearch-dsl-py-raise-an-exception-on-pypy-but-not-cpython/140343 "2018-07-17T14:22:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![seanthegeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/seanthegeek/32/33421_2.png) [@seanthegeek](https://discuss.elastic.co/u/seanthegeek)\
**Post date:** [July 17, 2018, 2:22pm UTC](https://discuss.elastic.co/t/why-does-elasticsearch-dsl-py-raise-an-exception-on-pypy-but-not-cpython/140343/1 "2018-07-17T14:22:55Z")

</div>

I have [some code](https://github.com/domainaware/parsedmarc/blob/master/parsedmarc/elastic.py#L306) 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
  forensic_doc.save()
File "/opt/venvs/parsedmarc/site-packages/elasticsearch_dsl/document.py", line 394, in save
  index=self._get_index(index),
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](https://github.com/elastic/elasticsearch-dsl-py/blob/master/elasticsearch_dsl/document.py#L138), 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](https://github.com/domainaware/parsedmarc/blob/master/parsedmarc/elastic.py#L136), 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=["127.0.0.1"], timeout=20)

doc = _ForensicReportDoc(feedback_type="foo")
doc.save()
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 14, 2018, 2:23pm UTC](https://discuss.elastic.co/t/why-does-elasticsearch-dsl-py-raise-an-exception-on-pypy-but-not-cpython/140343/2 "2018-08-14T14:23:08Z")

</div>

Closed on August 14, 2018, 2:23pm UTC

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