# Phrase\_suggester java api throwing exception

**URL:** <https://discuss.elastic.co/t/phrase-suggester-java-api-throwing-exception/27666>\
**Category:** Elasticsearch\
**Created:** [August 19, 2015, 10:48am UTC](https://discuss.elastic.co/t/phrase-suggester-java-api-throwing-exception/27666 "2015-08-19T10:48:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anusha6](https://avatars.discourse-cdn.com/v4/letter/a/a5b964/32.png) [@anusha6](https://discuss.elastic.co/u/anusha6)\
**Post date:** [August 19, 2015, 10:48am UTC](https://discuss.elastic.co/t/phrase-suggester-java-api-throwing-exception/27666/1 "2015-08-19T10:48:18Z")

</div>

Hi All,

AM using the Phrase\_Suggester Using java api as shown:

PhraseSuggestionBuilder phraseBuilder=new PhraseSuggestionBuilder("did-you-mean");  
phraseBuilder.field(suggest\_field);  
phraseBuilder.candidateGenerator(suggest\_field);

```
	SearchResponse response=client.prepareSearch(index).setTypes(type).setSize(0).addSuggestion(phraseBuilder).execute().actionGet();

```

getting the following exception:

Exception in thread "main" org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [query], all shards failed; shardFailures {[eqvyKeSMQFOkl7tbxmdr5w][ast][0]: SearchParseException[[ast][0]: from[-1],size[0]: Parse Failure [Failed to parse source [{"size":0,"suggest":{"did-you-mean":{"phrase":{"field":"id.raw"}}}}]]]; nested: ElasticsearchIllegalArgumentException[The required text option is missing]; }{[eqvyKeSMQFOkl7tbxmdr5w][ast][1]: SearchParseException[[ast][1]: from[-1],size[0]: Parse Failure [Failed to parse source [{"size":0,"suggest":{"did-you-mean":{"phrase":{"field":"id.raw"}}}}]]]; nested: ElasticsearchIllegalArgumentException[The required text option is missing]; }{[eqvyKeSMQFOkl7tbxmdr5w][ast][2]: SearchParseException[[ast][2]: from[-1],size[0]: Parse Failure [Failed to parse source [{"size":0,"suggest":{"did-you-mean":{"phrase":{"field":"id.raw"}}}}]]]; nested: ElasticsearchIllegalArgumentException[The required text option is missing]; }{[eqvyKeSMQFOkl7tbxmdr5w][ast][3]: SearchParseException[[ast][3]: from[-1],size[0]: Parse Failure [Failed to parse source [{"size":0,"suggest":{"did-you-mean":{"phrase":{"field":"id.raw"}}}}]]]; nested: ElasticsearchIllegalArgumentException[The required text option is missing]; }{[eqvyKeSMQFOkl7tbxmdr5w][ast][4]: SearchParseException[[ast][4]: from[-1],size[0]: Parse Failure [Failed to parse source [{"size":0,"suggest":{"did-you-mean":{"phrase":{"field":"id.raw"}}}}]]]; nested: ElasticsearchIllegalArgumentException[The required text option is missing]; }  
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.onFirstPhaseResult(TransportSearchTypeAction.java:238)  
at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$1.onFailure(TransportSearchTypeAction.java:184)  
at org.elasticsearch.search.action.SearchServiceTransportAction$23.run(SearchServiceTransportAction.java:565)  
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
at java.lang.Thread.run(Thread.java:745)

May I know how to rectify this????

---

<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:55pm UTC](https://discuss.elastic.co/t/phrase-suggester-java-api-throwing-exception/27666/2 "2017-07-05T23:55:02Z")

</div>


