1

I need to implement auto-complete feature in a field called "names" in my document. Here is the suggest query I am using for that:

{
"autoSuggest": {
"text": "word",
"completion": {
"field": "names"
}
}
}

Im getting the following error running this query:

{
"_shards":{
"total":5,
"successful":0,
"failed":5,
"failures":[
{
"index":"myindex",
"shard":0,
"reason":"BroadcastShardOperationFailedException[[names][0] ]; nested: ElasticsearchException[failed to execute suggest]; nested: ClassCastException[org.elasticsearch.index.mapper.core.StringFieldMapper cannot be cast to org.elasticsearch.index.mapper.core.CompletionFieldMapper]; "
}
....
]
}

What is the reason for this error? and what should i do to enable the auto-complete?

1 Answer 1

2

You need to define the suggester in the mapping first , only then it makes sense to call it out in the _suggest API. You can refer more on the subject here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.