Python and Elasticsearch Autocompletion issue

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/067ac9ac-deca-48bc-aa4c-9260aa4c7575%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.