# Python elasticsearch: always get exact match

**URL:** <https://discuss.elastic.co/t/python-elasticsearch-always-get-exact-match/71616>\
**Category:** Elasticsearch\
**Created:** [January 14, 2017, 3:25pm UTC](https://discuss.elastic.co/t/python-elasticsearch-always-get-exact-match/71616 "2017-01-14T15:25:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chocolate9624](https://avatars.discourse-cdn.com/v4/letter/c/f19dbf/32.png) [@chocolate9624](https://discuss.elastic.co/u/chocolate9624)\
**Post date:** [January 14, 2017, 3:25pm UTC](https://discuss.elastic.co/t/python-elasticsearch-always-get-exact-match/71616/1 "2017-01-14T15:25:36Z")

</div>

Hi, I am new to elasticsearch. There is an item in my index with the title: Using Python with Elasticsearch  
When I search for it, I always get zero hit except that I search "Using Python with Elasticsearch" exactly.  
like:

**1, The code**  
import elasticsearch  
INDEX\_NAME= 'test\_1'  
from elasticsearch import Elasticsearch  
es = Elasticsearch()  
es.index(index=INDEX\_NAME, doc\_type='post', id=1, body={  
'author': 'John Doe',  
'blog': 'Learning Elasticsearch',  
'title': 'Using Python with Elasticsearch',  
'tags': ['python', 'elasticsearch', 'tips'],  
})  
es.indices.refresh(index=INDEX\_NAME)  
res = es.indices.get(index=INDEX\_NAME)  
print res  
The output is:  
{u'test\_1': {u'warmers': {}, u'settings': {u'index': {u'number\_of\_replicas': u'1', u'number\_of\_shards': u'5', u'uuid': u'Z2KLxeQLRay4rFgdK4yo9A', u'version': {u'created': u'2020199'}, u'creation\_date': u'1484405704970'}}, u'mappings': {u'post': {u'properties': {u'blog': {u'type': u'string'}, u'title': {u'type': u'string'}, u'tags': {u'type': u'string'}, u'author': {u'type': u'string'}}}}, u'aliases': {}}}

**2, I change the mappings with the code below:**

INDEX\_NAME = 'test\_1'  
from elasticsearch import Elasticsearch  
es = Elasticsearch()  
request\_body = {  
'mappings':{  
'post': {  
'properties': {  
**'title': {'type':'text'}**  
}  
}  
}  
}  
if es.indices.exists(INDEX\_NAME):  
res = es.indices.delete(index = INDEX\_NAME)  
print(" response: '%s'" % (res))  
res = es.indices.create(index = INDEX\_NAME, body= request\_body, ignore=400)  
print res

The output is  
response: '{u'acknowledged': True}'  
{u'status': 400, u'error': {u'caused\_by': {u'reason': u\*\*'No handler for type [text] declared on field [title]\*\*', u'type': u'mapper\_parsing\_exception'}, u'root\_cause': [{u'reason': u'No handler for type [text] declared on field [title]', u'type': u'mapper\_parsing\_exception'}], u'type': u'mapper\_parsing\_exception', u'reason': u'Failed to parse mapping [post]: No handler for type [text] declared on field [title]'}}

**3, I update the elasticsearch from 1.9 to (5, 1, 0, 'dev')**

**4, I also try to change the mappings with the code below**

request\_body = {  
'mappings':{  
'post': {  
'properties': {  
**'title': {'type':'string', "index": "analyzed"}**  
}  
}  
}  
}  
but, it still cannot get the fuzzy match result!  
Thanks a lot!!

---

<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:** [February 11, 2017, 3:25pm UTC](https://discuss.elastic.co/t/python-elasticsearch-always-get-exact-match/71616/2 "2017-02-11T15:25:56Z")

</div>

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