HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityDoc feedbackLog In
GitHubNuGetDev CommunityDoc feedback

Classes in this topic are available in the following namespaces:

  • EPiServer.DataAnnotations

  • Mediachase.Search

  • Mediachase.Search.Extensions

  • Mediachase.Search.Extensions.Indexers

See also [Creating a search provider](🔗).

## Add index fields

The process of adding a new field can differ depending on the provider and where the data comes from. Here, we explain the steps for adding a field to the catalog index using Lucene and Solr providers.

When using Lucene, if you want to make a field searchable, decorate the property on the Catalog content model with the [Searchable] attribute. For legacy sites not using the Content model, the equivalent action is to go to the **meta-field configuration** in Commerce Manager and mark it **searchable**; the field is automatically added to the index.

When using Solr, add that field to the Solr configuration file, which is located in _APACHERROOT\\solr\\catalog\\conf\\catalog.schema.xml_.

**Example: adding an index field to the Solr schema**

To add a field programmatically if data comes from an external data source or needs to be computed, create a new class that inherits the existing CatalogIndexer.

## Create a search indexer

Search Indexer is a component that is responsible for assembling data into documents that Search Provider can then index. It typically connects subsystems like Catalogs, gets a list of changes, and submits to the search provider.

By default, Optimizely Customized Commerce indexes catalog data with the BaseCatalogIndexBuilder class or an inheriting class. However, third party implementations may implement ISearchIndexBuilder instead of extending BaseCatalogIndexBuilder.

The updated catalog event system uses the UpdateIndex method and calls it for any changed or deleted catalog entries. The parameter enumerates catalog entry IDs of changed or delete entries. The implementation is expected to update the search indexes appropriately for these entries.

If a transient error occurs (such as a network error when accessing a remote service), UpdateIndex should return false. The system may then retry the same batch of updates later. If a non-transient error occurs, the implementation should throw an exception.

An implementation of ISearchIndexBuilder should throw an exception from UpdateIndex if the updated event system is not supported, and scheduled tasks are used to execute BuildIndex.