Get the Source Data from Completion Suggest response

I am trying to use the Completion suggester for an Auto complete App. I am developing the client in Java and using "org.elasticsearch.client:elasticsearch-rest-high-level-client:7.1.0." library.

is there any way to extract the source data from the Suggest response ? I was only able to get the score and text from the Suggest response.

Code I have written to search -

SearchRequest searchRequest = new SearchRequest("my_entitiy");
CompletionSuggestionBuilder suggestionBuilder = new CompletionSuggestionBuilder("nameSuggest");

SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
        new SuggestBuilder().addSuggestion(SUGGESTION_NAME, suggestionBuilder));
SearchResponse searchResponse =, RequestOptions.DEFAULT);

Suggest suggest = searchResponse.getSuggest();
Suggest.Suggestion<Suggest.Suggestion.Entry<Suggest.Suggestion.Entry.Option>> suggesition =
List<String> suggestionList =  new ArrayList<>();
for (Suggest.Suggestion.Entry<Suggest.Suggestion.Entry.Option> entry : suggesition.getEntries()) {
  for(Suggest.Suggestion.Entry.Option option:entry.getOptions()){

When I checked the raw response elastic search is returning the complete document, But using java client library I dint find a way to get the source data ?

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