Quantcast
Channel: Optimizely Search & Navigation
Viewing all articles
Browse latest Browse all 6894

How can I create a "category" Facet based on the parent page.

$
0
0

I've got a heirarchy of pages such as 

- Root   - Category 1        - Page 1        - Page 2   - Category 2       - Page 3


I want to use Find to create a filter based on the Category page names. Here's what I've got so far, the bit I can't figure out is line 4

ar result = _searchClient.Search()
                                      .For(query)
                                      .Filter(x => x.Ancestors().Match(rootPageLink.ID.ToString()))
                                      .FilterFacet("Categories", x => x.ParentLink) // This doesn't work
                                      .HistogramFacetFor(x => x.Price, 100)
                                      .Skip((pageNumber - 1) * pageSize)
                                      .Take(pageSize)
                                      .GetContentResult();

Obviously this doesn't work because Filter() expects a Filter as the second argument but you can see what I'm trying to do.  It's roughly analagous to a SQL `GROUP BY ParentLink` and then display info like

Category 1 (2 pages)

Category 2 (1 page)

 


Viewing all articles
Browse latest Browse all 6894

Trending Articles