# Python and Elasticsearch Autocompletion issue

**URL:** <https://discuss.elastic.co/t/python-and-elasticsearch-autocompletion-issue/16746>\
**Category:** Elasticsearch\
**Created:** [April 1, 2014, 8:00pm UTC](https://discuss.elastic.co/t/python-and-elasticsearch-autocompletion-issue/16746 "2014-04-01T20:00:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![redrubia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/redrubia/32/1554_2.png) [@redrubia](https://discuss.elastic.co/u/redrubia)\
**Post date:** [April 1, 2014, 8:00pm UTC](https://discuss.elastic.co/t/python-and-elasticsearch-autocompletion-issue/16746/1 "2014-04-01T20:00:55Z")

</div>

Hi all,

So to begin. I am trying to add around 7.2k documents. No problem there.  
The issue is after I am not able to get any suggestions returned to me. So  
this is how the information is added:

def addVariantToElasticSearch(self,docId, companyId, companyName, parent,  
companyIndustry, variants, count,conn):  
body = { "company":{  
"company\_name": companyName,  
"parent": parent,  
"suggest": { "input": variants,  
"output": companyName,  
"weight": count,  
"payload": {"industry\_id": companyIndustry,  
"no\_of\_jobseekers":count,  
"company\_id": companyId  
}  
}  
}  
}  
res = conn.index(body=body, index="companies", doc\_type="company", id=docId  
)

The mapping and settings is defined as:

def setting():  
return { "settings" : {  
"index": {  
"number\_of\_replicas" : 0,  
"number\_of\_shards": 1  
},  
"analysis" : {  
"analyzer" : {  
"my\_edge\_ngram\_analyzer" : {  
"tokenizer" : "my\_edge\_ngram\_tokenizer",  
"filter":["standard", "lowercase"]  
}  
},  
"tokenizer" : {  
"my\_edge\_ngram\_tokenizer" : {  
"type" : "edgeNGram",  
"min\_gram" : "1",  
"max\_gram" : "5",  
"token\_chars": ["letter", "digit"]  
}  
}  
}  
},  
"mappings": {  
"company" : {  
"properties" : {  
"name" : { "type" : "string" },  
"industy": {"type": "integer"},  
"count" : {"type": "long" },  
"parent": {"type": "string"},  
"suggest" : {  
"type" : "completion",  
"index\_analyzer": "my\_edge\_ngram\_analyzer",  
"search\_analyzer": "my\_edge\_ngram\_analyzer",  
"payloads": True  
}  
}  
}  
}  
}

Index creation:

def createMapping(es):  
settings = setting()  
es.indices.create(index="companies", body=settings)

I call `createMapping` which uses `setting()`, then add each variant -  
surrounded by a try,except -\> causes no issue. I can see all my documents  
added in the browser as well as looking at the status, settings and  
mappings.

But when I use a curl request as below, I get no results. (See curl and  
output beneath)

curl -X POST localhost:9200/companies/\_suggest -d '  
{  
"company-suggest" : {  
"text" : "1800",  
"completion" : {  
"field" : "suggest"  
}  
}  
}'

{

"\_shards" : {

```
"total" : 1,

"successful" : 1,

"failed" : 0

```

},

"suggest" : [ {

```
"text" : "ruby",

"offset" : 0,

"length" : 4,

"options" : []

```

} ]

I am currently using ES 1.1.0. I have tried both Python API 0.4 and 1.1.0  
with no luck (I tried 0.4 as a result of 1.1.0 not working although I know  
it isn't best to due to compatibility issues with version of ES). I have  
also been able to add the same settings with mappings via curl and added a  
company which I have been able to retrieve by this curl above.

I'm not sure exactly where the issue lies. I have looked at the Data folder  
in ES to ensure it has been created, as well as the browser. I have also  
ensured only a single ES instance is running.

Any help greatly appreciated,

Ruby

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/067ac9ac-deca-48bc-aa4c-9260aa4c7575%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/067ac9ac-deca-48bc-aa4c-9260aa4c7575%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:38am UTC](https://discuss.elastic.co/t/python-and-elasticsearch-autocompletion-issue/16746/2 "2017-07-06T01:38:56Z")

</div>


