Example usage for org.springframework.data.solr.core.query.result FacetPage getFacetResultPages

List of usage examples for org.springframework.data.solr.core.query.result FacetPage getFacetResultPages

Introduction

In this page you can find the example usage for org.springframework.data.solr.core.query.result FacetPage getFacetResultPages.

Prototype

Collection<Page<FacetFieldEntry>> getFacetResultPages();

Source Link

Usage

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 va  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;
}