# Python doesn't send docs to elasticsearch after set mappings

**URL:** <https://discuss.elastic.co/t/python-doesnt-send-docs-to-elasticsearch-after-set-mappings/87143>\
**Category:** Elasticsearch\
**Created:** [May 25, 2017, 2:55pm UTC](https://discuss.elastic.co/t/python-doesnt-send-docs-to-elasticsearch-after-set-mappings/87143 "2017-05-25T14:55:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![filippo\_leoncini](https://avatars.discourse-cdn.com/v4/letter/f/ee7513/32.png) [@filippo\_leoncini](https://discuss.elastic.co/u/filippo_leoncini)\
**Post date:** [May 25, 2017, 2:55pm UTC](https://discuss.elastic.co/t/python-doesnt-send-docs-to-elasticsearch-after-set-mappings/87143/1 "2017-05-25T14:55:34Z")

</div>

I have uploaded many time doc to elasticseatch without specify the mapping without any problem, instead this time I need to map the fields in order to set the format of my timestamp field.

When I launch the script it seems to run without problems but at the end I can't find any documents uploaded at the index in elasticsearch.

Here my script

```
from elasticsearch import Elasticsearch

```

import json

es= Elasticsearch()

INDEX\_NAME = 'technogym\_error\_time'  
TYPE\_NAME = 'technogym\_error\_time'  
ID\_FIELD = 'id'

bulk\_data =

with open("C:/Users/Filippo-Leoncini/Documents/Lavoro/IBM/Technogym/Dashboard/dati/dati\_partenza/dati\_nuovi/20170515 11.42RetrainExtraction") as data\_file:  
data =json.load(data\_file)

for i in data["rows"]:  
document\_id = i["id"]  
time\_stamp = i["doc"]["timestamp"][5:-4]  
error = i["doc"]['review\_reason']  
node\_list=({"timestamp": time\_stamp.encode('utf-8'),"document\_id": document\_id.encode('utf-8'),"error":error.encode('utf-8')})  
op\_dict = {  
"index": {  
"\_index": INDEX\_NAME,  
"\_type": TYPE\_NAME,  
"\_id": document\_id  
}  
}  
bulk\_data.append(op\_dict)  
bulk\_data.append(node\_list)

settings = {  
"settings": {  
"number\_of\_shards": 1,  
"number\_of\_replicas": 0  
},  
"mappings": {  
"technogym\_error\_time": {  
"properties": {  
"timestamp":{  
"type":"date",  
"format":"dd MM YYYY HH:mm:ss"  
},  
"error":{  
"type":"string"  
}  
}  
}  
}  
}

es.indices.create(index= INDEX\_NAME, body=settings)  
es.bulk(body= bulk\_data, index = INDEX\_NAME, doc\_type = TYPE\_NAME)

Here a screenshot of my elasticsearch indices

 ![](https://us1.discourse-cdn.com/elastic/original/3X/5/7/57829be4f52f9d1babb8b096b79f27578ff60585.PNG)

And here is what I get on Kibana

 ![](https://us1.discourse-cdn.com/elastic/original/3X/b/4/b49891a200a6e4ff9f04e4a45e6d79d5ec242283.png)

Thanks

---

<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:** [June 22, 2017, 2:55pm UTC](https://discuss.elastic.co/t/python-doesnt-send-docs-to-elasticsearch-after-set-mappings/87143/2 "2017-06-22T14:55:41Z")

</div>

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