Skip to content

Commit

Permalink
Merge pull request #3402 from atlanhq/autocomplete
Browse files Browse the repository at this point in the history
feat: update suggestion response to include sources
  • Loading branch information
sumandas0 authored Aug 19, 2024
2 parents ea92573 + 6e8f8a6 commit cd16afd
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public SuggestionResponse searchSuggestions(String queryStr) throws IOException
LinkedHashMap suggestions = suggestionMap.get(0);
List<LinkedHashMap> options = (List<LinkedHashMap>) suggestions.get("options");
for (LinkedHashMap option : options) {
suggestionResponse.addSuggestion((String) option.get("text"));
suggestionResponse.addSuggestion((LinkedHashMap) option.get("_source"));
}

return suggestionResponse;
Expand All @@ -63,19 +63,25 @@ public SuggestionResponse searchSuggestions(String queryStr) throws IOException
public class SuggestionResponse {

public SuggestionResponse() { }
private List<String> suggestions = new ArrayList<>();
private List<LinkedHashMap> suggestions = new ArrayList<>();
private final List<LinkedHashMap> sources = new ArrayList<>();

public List<String> getSuggestions() {
public List<LinkedHashMap> getSuggestions() {
return suggestions;
}

public void addSuggestion(String suggestion) {
public void addSuggestion(LinkedHashMap suggestion) {
this.suggestions.add(suggestion);
}

public void setSuggestions(List<String> suggestions) {
public void addSource(LinkedHashMap source) {
this.sources.add(source);
}

public void setSuggestions(List<LinkedHashMap> suggestions) {
this.suggestions = suggestions;
}

}


Expand Down

0 comments on commit cd16afd

Please sign in to comment.