# Get the Source Data from Completion Suggest response

**URL:** <https://discuss.elastic.co/t/get-the-source-data-from-completion-suggest-response/235869>\
**Category:** Elasticsearch\
**Created:** [June 5, 2020, 12:16am UTC](https://discuss.elastic.co/t/get-the-source-data-from-completion-suggest-response/235869 "2020-06-05T00:16:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tedks](https://avatars.discourse-cdn.com/v4/letter/t/3ec8ea/32.png) [@tedks](https://discuss.elastic.co/u/tedks)\
**Post date:** [June 5, 2020, 12:16am UTC](https://discuss.elastic.co/t/get-the-source-data-from-completion-suggest-response/235869/1 "2020-06-05T00:16:31Z")

</div>

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 -

```auto
SearchRequest searchRequest = new SearchRequest("my_entitiy");
CompletionSuggestionBuilder suggestionBuilder = new CompletionSuggestionBuilder("nameSuggest");
suggestionBuilder.size(10).prefix(input).skipDuplicates(true);

SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.suggest(
        new SuggestBuilder().addSuggestion(SUGGESTION_NAME, suggestionBuilder));
searchRequest.source(searchSourceBuilder);
SearchResponse searchResponse = elasticClient.search(searchRequest, RequestOptions.DEFAULT);

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

```

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 ?

---

<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 3, 2020, 12:16am UTC](https://discuss.elastic.co/t/get-the-source-data-from-completion-suggest-response/235869/2 "2020-07-03T00:16:37Z")

</div>

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