Changeset 4384
- Timestamp:
- 01/29/14 13:22:07 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vlo/branches/vlo-2.18/vlo_web_app/src/main/java/eu/clarin/cmdi/vlo/dao/AutoCompleteDao.java
r2768 r4384 11 11 /** 12 12 * DAO that delivers suggestions for incomplete terms (autocomplete function) 13 * 13 * 14 14 * @author Thomas Eckart 15 15 * 16 16 */ 17 17 public class AutoCompleteDao extends SolrDao { 18 19 /** 20 * Returns list of suggestions for incomplete input (used for autocomplete function) 21 * @param input user input 22 * @return list of suggestions 23 */ 24 public List<String> getChoices(String input) { 25 List<String> choices = new ArrayList<String>(); 26 27 SolrQuery query = new SolrQuery(); 28 query.setQuery(input.toLowerCase()); 29 query.setQueryType("/suggest"); 30 QueryResponse response = fireQuery(query); 31 if(response.getSpellCheckResponse() != null) { 32 List<Suggestion> suggestions = response.getSpellCheckResponse().getSuggestions(); 33 if(suggestions.size() > 0) { 34 Iterator<String> iter = suggestions.get(0).getAlternatives().iterator(); 35 while(iter.hasNext()) { 36 choices.add(iter.next()); 37 } 38 } 39 } 40 41 return choices; 42 } 18 19 /** 20 * Returns list of suggestions for incomplete input (used for autocomplete 21 * function) 22 * 23 * @param input user input 24 * @return list of suggestions 25 */ 26 public List<String> getChoices(String input) { 27 List<String> choices = new ArrayList<String>(); 28 29 if (input != null) { 30 SolrQuery query = new SolrQuery(); 31 query.setQuery(input.toLowerCase()); 32 query.setQueryType("/suggest"); 33 QueryResponse response = fireQuery(query); 34 if (response.getSpellCheckResponse() != null) { 35 List<Suggestion> suggestions = response.getSpellCheckResponse().getSuggestions(); 36 if (suggestions.size() > 0) { 37 Iterator<String> iter = suggestions.get(0).getAlternatives().iterator(); 38 while (iter.hasNext()) { 39 choices.add(iter.next()); 40 } 41 } 42 } 43 } 44 45 return choices; 46 } 43 47 }
Note: See TracChangeset
for help on using the changeset viewer.