@ResponseBody @RequestMapping( value = "/autocomplete/" + COMPONENT_UID_PATH_VARIABLE_PATTERN, method = {RequestMethod.GET, RequestMethod.POST}) public AutocompleteResultData getAutocompleteSuggestions( @PathVariable final String componentUid, @RequestParam("term") final String term) throws CMSItemNotFoundException { final SearchStateData searchState = createSearchStateData(term, true); final AutocompleteResultData resultData = new AutocompleteResultData(); final SearchBoxComponentModel component = (SearchBoxComponentModel) cmsComponentService.getSimpleCMSComponent(componentUid); if (component.isDisplaySuggestions()) { resultData.setSuggestions( subList( b2bSolrProductSearchFacade.autocomplete(searchState), component.getMaxSuggestions())); } if (component.isDisplayProducts()) { final SearchPageData<ProductData> pageData = b2bSolrProductSearchFacade.search(searchState, null); resultData.setProducts(subList(pageData.getResults(), component.getMaxProducts())); } return resultData; }
@ResponseBody @RequestMapping( value = "/autocomplete", method = {RequestMethod.GET, RequestMethod.POST}) public List<String> getAutocompleteSuggestions(@RequestParam("term") final String term) { final SearchStateData searchState = createSearchStateData(term, true); final List<String> terms = new ArrayList<String>(); for (final AutocompleteSuggestionData termData : b2bSolrProductSearchFacade.autocomplete(searchState)) { terms.add(termData.getTerm()); } return terms; }