@ResponseBody @RequestMapping( value = "/autocomplete/" + COMPONENT_UID_PATH_VARIABLE_PATTERN, method = RequestMethod.GET) public AutocompleteResultData getAutocompleteSuggestions( @PathVariable final String componentUid, @RequestParam("term") final String term) throws CMSItemNotFoundException { final AutocompleteResultData resultData = new AutocompleteResultData(); final SearchBoxComponentModel component = (SearchBoxComponentModel) cmsComponentService.getSimpleCMSComponent(componentUid); if (component.isDisplaySuggestions()) { resultData.setSuggestions( subList( productSearchFacade.getAutocompleteSuggestions(term), component.getMaxSuggestions())); } if (component.isDisplayProducts()) { resultData.setProducts( subList(productSearchFacade.textSearch(term).getResults(), component.getMaxProducts())); } return resultData; }
@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; }