# Elastic Search Python mappings

**URL:** <https://discuss.elastic.co/t/elastic-search-python-mappings/78797>\
**Category:** Elasticsearch\
**Created:** [March 16, 2017, 6:19am UTC](https://discuss.elastic.co/t/elastic-search-python-mappings/78797 "2017-03-16T06:19:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Suran\_Kularatna](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@Suran\_Kularatna](https://discuss.elastic.co/u/Suran_Kularatna)\
**Post date:** [March 16, 2017, 6:19am UTC](https://discuss.elastic.co/t/elastic-search-python-mappings/78797/1 "2017-03-16T06:19:54Z")

</div>

Hi,

I've written some python code to read a csv and create an index

#!/usr/local/bin/python

import sys  
import os  
import csv  
import codecs  
from elasticsearch import Elasticsearch

csvfile="fintech\_investments.csv"

#create the index mapping

mapping = {  
"fintech-map": {  
"properties": {  
"Year": {"type": "integer"},  
"Country": {"type": "keyword", "index": "not\_analyzed", "analyzer": "snowball"},  
"Company": {"type": "keyword", "index": "not\_analyzed", "analyzer": "snowball"},  
"Category": {"type": "keyword","index": "not\_analyzed"},  
"Investment Amount Received": {"type": "float","index": "not\_analyzed"},  
"Description": {"type": "keyword", "index": "not\_analyzed"}  
}  
}  
}

es = Elasticsearch(['10.132.32.75'])  
if not es.indices.exists("fintech-investments"):  
es.indices.create("fintech-investments")

es.indices.put\_mapping(index="fintech-investments",doc\_type="fintech-map",body=mapping)

with open(csvfile,'rb') as csvdata:  
reader=csv.reader(csvdata,delimiter=",",quotechar='"')  
reader.next()  
for id, row in enumerate(reader):  
print row  
content = {  
"Year":row[0],  
"Country":row[1],  
"Company":row[2],  
"Category":row[3],  
"Investment Amount Received":row[4],  
"Description":row[5]  
}  
es.index(index="fintech-investments",doc\_type="fintech-map",id=id,body=content)

whilst, this works, i would like to change the analyser type where in the code do i define the analyser type ?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [March 16, 2017, 7:38am UTC](https://discuss.elastic.co/t/elastic-search-python-mappings/78797/2 "2017-03-16T07:38:00Z")

</div>

Please use code formatting, otherwise it makes things very hard to read.

> [@Suran\_Kularatna](#):
>
> i would like to change the analyser type where in the code do i define the analyser type ?

You already have that, it's at the end of this line;

> [@Suran\_Kularatna](#):
>
> "Country": {"type": "keyword", "index": "not\_analyzed", "analyzer": "snowball"},

---

<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:** [April 13, 2017, 7:38am UTC](https://discuss.elastic.co/t/elastic-search-python-mappings/78797/3 "2017-04-13T07:38:20Z")

</div>

Closed on April 13, 2017, 7:38am UTC

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