Hide menu Last updated: Feb 20 2017
Area: Episerver Commerce Applies to versions: 10 and higher
Other versions:


Episerver Commerce includes an extensive, system-wide search engine. You can make any information available to the search engine, even if that information is not in the Episerver Commerce database. Some systems, such as Catalog and Orders, have additional search features. 

How it works

Episerver Commerce has its own pluggable API for search providers. The search engine is based on the ASP.NET provider model, meaning you can write your own providers to search servers. Episerver Commerce comes with providers for Lucene and SOLR.

The search provier system is used to support various UI components, including the different search features in Commerce Manager and the search in the Catalog UI.

It can also be used to build user-facing featuers in the site implementation. An even more powerful approach to that is to integrate Episerver Commerce with Episerver Find to create more advanced search-based navigation and filtering for websites.

Classes in this topic are available in the following namespaces:


Episerver Commerce has a layer built on top of Lucene for easy integration. A MediachaseSearch layer provides a base layer to simplify the interface. This base creates an index for any data source, while you still have access to the Lucene classes. Searchable data is written to a file index.

SearchExtensions provide catalog indexing and a searching implementation using the MediachaseSearch layer, which is built into Commerce Manager and includes several controls making use of this implementation. You can create you own search implementation on top of MediachaseSearch.


To make data available, you must first index it by calling the Mediachase.Search.SearchManager.BuildIndex(bool rebuild) method. Click the Build or Rebuild buttons in Commerce Manager to call the method.

The individual indexer implementations are defined in the mediachase.search.config file. The default catalog indexer included, Mediachase.Search.Extensions.Indexers.CatalogIndexBuilder, Mediachase.Search.Extensions, reads the catalog data and calls the SearchProvider.Index(string applicationName, string scope, ISearchDocument document) method.

Implement the method by the provider that is currently configured. The provider is passed an ISearchDocument, containing properties that need to be indexed. You can replace the indexer completely or extend the existing indexer by inheriting CatalogIndexBuilder class and overriding OnCatalogEntryIndex method. You also can add new indexers.

By default, the indexer only populates fields that are marked searchable in the metafield configuration, or decorated with the [Searchable] attribute on catalog content models, and some system fields like price, name, and code. Depending on the provider, additional configuration changes need to be made to index those fields.

Calling BuildIndex with rebuild = false only adds indexes that changed since the last index was created. The system tracks when the last index was performed using the .build file. Location of the .build file is configured inside Mediachase.Search.config file for each indexer defined.

Example: build index command

SearchManager searchManager = new SearchManager(applicationName);

Catalog metadata fields have options that let you specify:

  • Whether a field is added to the index. This alone does not make the field searchable.
  • Whether a field value is stored or not. Stored = stored in an uncompressed format. Not stored = putting the value into the index in a compressed format. You only store a value if you will use it as part of the text displayed in search results.
  • Whether a field is tokenized. A field must be tokenized to be searchable. When a field is tokenized, the text is broken into individual, searchable words, and common words are omitted.


When the data is indexed, this index is searched. Search is done by calling the ISearchResults Mediachase.Search.Search(ISearchCriteria criteria) method. The method call is handled by the configured search provider and returns the ISearchResults interface.

Example: simple catalog search

CatalogEntrySearchCriteria criteria = new CatalogEntrySearchCriteria();
criteria.SearchPhrase = "canon";
SearchManager manager = new SearchManager(AppContext.Current.ApplicationName);
SearchResults results = manager.Search(criteria);

The search phrase can contain complex search syntax that is specific to a provider used.

Facets and filters

Another capability extending the Lucene.NET functionality is the ability to create Facets, which are a type of filtering that can further narrow a search. In the configuration file, facets such as SimpleValue, PriceRangeValue, and RangeValue types can be found.

Facets are organized into facet groups. A facet group is referred to as a Filter in the configuration file. For instance, a Color facet group can have a Red facet. In the configuration, Color would be the filter and Red would be a SimpleValue. A facet group is linked to a particular field or meta-field. You can specify facets as part of the ISearchCriteria interface.

The front end includes controls that read a special configuration file to automatically populate the facet property of the ISearchCriteria interface. These filters are stored in Mediachase.Search.Filters.config. To add a new filter, add a new field to the index and add a record to the configuration file. The filter appears as soon as the data is available.

Related topics