This document describes how to extend your EPiServer Commerce solution by creating your own search provider. the examples here are based on Lucene and SOLR. Refer also to Customizing Search for related information.
Classes referred to here are available in the following namespaces:
Implementing a search provider
To implement a new search provider or to extend or replace an existing one, you will need to create a new class that implements the SearchProvider abstract class. That class contains one method that performs the search, while the rest deals with indexing the data. It is typically much easier to take one of the existing implementations (SOLR or Lucene) as a starting point.
Example: implementing the SearchProvider class
C#
public abstract class SearchProvider : ProviderBase
{
public abstract string QueryBuilderType { get; }
public abstract ISearchResults Search(string applicationName, ISearchCriteria criteria);
public abstract void Index(string applicationName, string scope, ISearchDocument document);
public abstract int Remove(string applicationName, string scope, string key, string value);
public abstract void RemoveAll(string applicationName, string scope);
public abstract void Close(string applicationName, string scope);
public abstract void Commit(string applicationName);
}
The main classes in this SOLR implementation example are:
- SolrSearchProvider - the main class.
- SolrSearchQueryBuilder - converts ISearchCriteria to the provider native language and is called within the Search method of the provider.
See also
Do you find this information helpful? Please log in to provide feedback.