# Completion suggester

**URL:** <https://discuss.elastic.co/t/completion-suggester/31472>\
**Category:** Elasticsearch\
**Created:** [October 1, 2015, 11:29am UTC](https://discuss.elastic.co/t/completion-suggester/31472 "2015-10-01T11:29:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![siddharth\_gupta](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@siddharth\_gupta](https://discuss.elastic.co/u/siddharth_gupta)\
**Post date:** [October 1, 2015, 11:29am UTC](https://discuss.elastic.co/t/completion-suggester/31472/1 "2015-10-01T11:29:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![davidbkemp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidbkemp/32/594_2.png) [@davidbkemp](https://discuss.elastic.co/u/davidbkemp)\
**Post date:** [October 2, 2015, 4:34am UTC](https://discuss.elastic.co/t/completion-suggester/31472/2 "2015-10-02T04:34:51Z")

</div>

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)

---

<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 5, 2017, 11:47pm UTC](https://discuss.elastic.co/t/completion-suggester/31472/3 "2017-07-05T23:47:07Z")

</div>


