Completion suggester

Hello,

I want to use completion suggester and find it quite complex.

I am facing the error below while using completion suggester=>

org.elasticsearch.index.mapper.core.StringFieldMapper cannot be cast to org.elasticsearch.index.mapper.core.CompletionFieldMapper

Here is my mapping for the field for which I am trying to use the completion suggester =>

"MY_FIELD" : {
"type" : "string",
"term_vector": "with_positions_offsets_payloads",
"store" : true,
"analyzer" : "stopword_analyzer",
"fields" : {
"suggest" : { "type" : "completion",
"analyzer" : "simple_analyzer",
"search_analyzer" : "simple_analyzer",
"payloads" : true
}
}
}

This is the code I am using=>
.addSuggestion(SuggestBuilders.completionSuggestion("FIELD_suggest").text(query).field("MY_FIELD").size(3))

Can anybody help me with this error ?

Thanks
Siddharth.

In your query, try specifying the field name as "MY_FIELD.suggest" instead of "MY_FIELD".

i.e.

.addSuggestion(SuggestBuilders.completionSuggestion("FIELD_suggest").text(query).field("MY_FIELD.suggest").size(3)