Completion Suggestion Java API for ElasticSearch 5.5.1

I want to refer the following example to code the suggestions function with java for elasticsearch 5.5.1,
but I could not find the prepareSearch , addSuggestion methods like the example.
Could you help me to solve the problem , thanks very much.

CompletionSuggestionBuilder compBuilder = new CompletionSuggestionBuilder("complete");
compBuilder.text("n..");
compBuilder.field("suggest");

SearchResponse searchResponse = localClient.prepareSearch(INDEX_NAME)
.setTypes("completion")
.setQuery(QueryBuilders.matchAllQuery())
.addSuggestion(compBuilder)
.execute().actionGet();

CompletionSuggestion compSuggestion = searchResponse.getSuggest().getSuggestion("complete");

it's not addSuggestion, but just suggest() - have you tried that?

See https://github.com/elastic/elasticsearch/blob/5.5/core/src/main/java/org/elasticsearch/action/search/SearchRequestBuilder.java

Thank you very much.
I have noticed the java api changes.
https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking_50_java_api_changes.html

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.