List of usage examples for org.springframework.data.solr.core.query.result FacetFieldEntry getValue
String getValue();
From source file:com.eurodisney.streamit.solr.product.web.SearchController.java
@ResponseBody @RequestMapping(value = "/autocomplete", produces = "application/json") public Set<String> autoComplete(Model model, @RequestParam("term") String query, @PageableDefault(page = 0, size = 1) Pageable pageable) { if (!StringUtils.hasText(query)) { return Collections.emptySet(); }//from w w w. j a v a 2s . c o m FacetPage<Product> result = productService.autocompleteNameFragment(query, pageable); Set<String> titles = new LinkedHashSet<String>(); for (Page<FacetFieldEntry> page : result.getFacetResultPages()) { for (FacetFieldEntry entry : page) { if (entry.getValue().contains(query)) { // we have to do this as we do not use terms vector or a string field titles.add(entry.getValue()); } } } return titles; }
From source file:com.lijojacob.mls.productcatalog.index.ProductDocumentServiceImpl.java
private SearchResultDTO processSearchResults(FacetPage<ProductDocument> productDocumentsFacetPage) { SearchResultDTO result = new SearchResultDTO(); DocumentResults documentResults = new DocumentResults(); documentResults.setResults(productDocumentsFacetPage.getContent()); documentResults.setTotalPages(productDocumentsFacetPage.getTotalPages()); result.setDocuments(documentResults); if (CollectionUtils.isNotEmpty(productDocumentsFacetPage.getFacetFields())) { Map<String, List<Facet>> facetMap = new HashMap<String, List<Facet>>(); FacetResults facetResults = new FacetResults(); for (Field facetField : productDocumentsFacetPage.getFacetFields()) { if (null != productDocumentsFacetPage.getFacetResultPage(facetField)) { List<FacetFieldEntry> facetFieldEntryList = productDocumentsFacetPage .getFacetResultPage(facetField).getContent(); List<Facet> facets = new ArrayList<Facet>(); for (FacetFieldEntry facetFieldEntry : facetFieldEntryList) { Facet facet = new Facet(); facet.setValue(facetFieldEntry.getValue()); facet.setCount(facetFieldEntry.getValueCount()); facets.add(facet);/* w w w. j a v a 2 s . c o m*/ } facetMap.put(facetField.getName(), facets); } } facetResults.setResults(facetMap); result.setFacets(facetResults); } return result; }