# Problems with entering data using Elasticsearch DSL

**URL:** <https://discuss.elastic.co/t/problems-with-entering-data-using-elasticsearch-dsl/185643>\
**Category:** Elasticsearch\
**Created:** [June 13, 2019, 12:45pm UTC](https://discuss.elastic.co/t/problems-with-entering-data-using-elasticsearch-dsl/185643 "2019-06-13T12:45:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![semplicesteak](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@semplicesteak](https://discuss.elastic.co/u/semplicesteak)\
**Post date:** [June 13, 2019, 12:45pm UTC](https://discuss.elastic.co/t/problems-with-entering-data-using-elasticsearch-dsl/185643/1 "2019-06-13T12:45:55Z")

</div>

Hello,  
I try to use Elasticsearch DSL docs' Persistence Example to input data. ([https://elasticsearch-dsl.readthedocs.io/en/latest/](https://elasticsearch-dsl.readthedocs.io/en/latest/)) But it can't run on python3. Code show as below:

from datetime import datetime  
from elasticsearch\_dsl import Document, Date, Integer, Keyword, Text  
from elasticsearch\_dsl.connections import connections

connections.create\_connection(hosts=['localhost'])

class Article(Document):  
title = Text(analyzer='snowball', fields={'raw': Keyword()})  
body = Text(analyzer='snowball')  
tags = Keyword()  
published\_from = Date()  
lines = Integer()

```
class Index:
    name = 'blog'
    settings = {
      "number_of_shards": 2,
    }

def save(self, ** kwargs):
    self.lines = len(self.body.split())
    return super(Article, self).save(** kwargs)

def is_published(self):
    return datetime.now() >= self.published_from

```

Article.init()

article = Article(meta={'id': 42}, title='Hello world!', tags=['test'])  
article.body = ''' looong text '''  
article.published\_from = datetime.now()  
article.save()

article = Article.get(id=42)  
print(article.is\_published())

print(connections.get\_connection().cluster.health())

The error is that ImportError: cannot import name 'Document' from 'elasticsearch\_dsl'.  
And I try to use DocType to replace Document. The program tells me that ValueError: Empty value passed for a required argument 'index'.  
So I change \</Article.init()\> to \</Article.init('blog')\>. It also cannot run. It shows that elasticsearch.exceptions.RequestError: RequestError(400, 'mapper\_parsing\_exception', 'Root mapping definition has unsupported parameters: [doc : {properties={published\_from={type=date}, title={analyzer=snowball, fields={raw={type=keyword}}, type=text}, body={analyzer=snowball, type=text}, lines={type=integer}, tags={type=keyword}}}]') .  
I want to know how could I deal with this problem?

My system operation is Win10.  
Python version: 3.7  
Elasticsearch version: 7.1.1

I try to use elasticsearch version 6.8 and elasticsearch\_dsl version 6.4.0. The problem is solved. But I still want to use the latest version^\_^

---

<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:** [July 11, 2019, 12:46pm UTC](https://discuss.elastic.co/t/problems-with-entering-data-using-elasticsearch-dsl/185643/2 "2019-07-11T12:46:02Z")

</div>

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