Today, I spent a few hours on researching about how to implement custom index field with Examine in Umbraco7. There are plenty of resources talking about IndexUserField, IndexAttributeField but none of them is actually using custom field.

So I looked into the Umbraco API, and worked it out. If you knew Examine, you can ignore this part, and jump to the solution straightaway. Otherwise, I want to give you a little intro to what is Examine.

What is Examine?

Examine wraps the Lucene.Net API, which makes it easy for Umbraco developers to build index and search data [1]. Lucene open source search engine enable us to build a search driven and a high performance website.

What is custom index field?

Custom index field, also called "computed filed", is normally not existing in your database, but frequently used in program.

How to implement?

There might be other ways to implement "custom index field", but here I am going to introduce "UmbracoContentIndexer". UmbracoContentIndexer is an indexer for creating index document by getting data from Umbraco nodes. All you need to do is to add "custom index field" by overriding "GetDataToIndex" method.

[1] http://umbraco.com/follow-us/blog-archive/2011/9/16/examining-examine


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.



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.


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.