Documentation

Ucommerce includes full API reference documentation and lots of helpful articles to help you build your e-commerce site as effortlessly as possible.

Topics Payment Providers
v7.18

Index definitions

Index definitions helps Ucommerce figure out what data you want in your index as well as what data type it has and how you can search the index.

It is a generic concept which means you can define any index of data you could possible imagine.

OOTB Index Definitions

Ucommerce ships with a couple of index definitions out of the box. We realize that this isn't enough, and that you possibly have an opinion on how your data should look like.

Ucommerce ships with an index per catalog concept e.g.

  • Stores
  • Catalogs
  • Categories
  • Products

A word on definitions and custom properties on catalog items

Each catalog item type has the ability to be extended with custom data via definitions. This data will not be part of the index unless you override the default index definitions.

Out of the box all Index Definitions will have the standard data fields indexes like name and multi lingual properties as well as images and other essential parts of the catalog data set.

All Default Index definitions can be found under the following namespace.

    using Ucommerce.Search.Definitions;
    using Ucommerce.Search.Extensions;

Product Index Definition

To have custom data defined in the index you can create an implementation that inherits the default product index defitions.

    
    public class AvenueProductIndexDefinition : Ucommerce.Search.Definitions.DefaultProductsIndexDefinition
    {
        public AvenueProductIndexDefinition() : base()
        {
            this.Field(p => p["ShowOnHomepage"], typeof(bool));
            this.Field(p => p["CollarSize"], typeof(string));
            this.Field(p => p["ShoeSize"], typeof(string));
            this.Field(p => p["Colour"], typeof(string));
            this.PricesField(p => p.UnitPrices);
            this.Facet("Colour");
            this.Facet("CollarSize");
            this.Facet("ShoeSize");
        }
    }
    
    

The code above defines the data needed to power Avenue-Clothing. Now Ucommerce will pick this definition up when the configuration has been created as well.

The following configuration register the avenue-clothing product index definition and now the right data needed is indexed properly.

    
    
            <component id="ProductsIndexDefinition"
                       service="Ucommerce.Search.IIndexDefinition`1[[Ucommerce.Search.Models.Product, Ucommerce.Search]], Ucommerce.Search"
                       type="AvenueClothing.Search.AvenueProductIndexDefinition, AvenueClothing">
            </component>