0 Comments

What is Faceted Search

Faceted search is a technique for accessing information organized according to a faceted classification system, allowing users to explore a collection of information by applying multiple filters (Cited by Wikipedia). There are lots of resources about the great feature in Sitecore 7, however few of them is actually explain how it can be implement in terms of coding. This article is intended to use a simple example to explain how it works in Sitecore 7.

Concept

Example

As per the concept above, let's take an example, saying you have a car sale website, one of the categories of a car will be body type i.e.Sedan, Hachback. Also, there are 100 cars that body type is Sedan, and 200 are hatchback.

Code

The below query is to search cars that made before 2013, and set facets for BodyType, Color, and Transmission.

Based on the above query, the Facets category values will be the actual BodyType, Color, and Transmission, the aggregate will be the number of cars under that category. For instance, Category[0] is BodyType, Category[0].Values[0] is Sedan, Category[0].Values[0].aggregate is 100.