Index Definitions
Index definitions specify the data type, content, and searchability of indexed data in Ucommerce.
Default index definitions
Ucommerce ships with built-in index definitions for the following entities:
Store (
DefaultStoresIndexDefinition
)Catalog (
DefaultCatalogsIndexDefinition
)Category (
DefaultCategoriesIndexDefinition
)Product (
DefaultProductsIndexDefinition
)PriceGroup (
DefaultPriceGroupsIndexDefinition
)ProductPrice (
DefaultPricesIndexDefinition
)
Customizing an index definition
To have custom data, e.g., user-defined fields, in the index, you must create a custom index definition by creating a class that either inherits from IIndexDefintion<SearchModelType>
or the default definition as in the example below.
After defining a custom index, it must override the default in the service collection of your app.
A rebuild of the indices is needed after changing the index definition.
Enum fields
When adding a user-defined enum, e.g. Color
, use the type UserDefinedEnum
in the index definition as shown in the example above. This type has special handling in the index to make sure that the display name and value of the enum is handled correctly, e.g.:
Notice that the Coupons
property has DisplayName
and Value
properties while Downloadable
does not. This is because Coupons
is defined as UserDefinedEnum
while Downloadable
is defined as bool
.
Multi-value fields
When adding a multi-value field, e.g. available colors
, the API can automatically split this correctly into a list of possible values as shown below.
Example: Red and Green are the available colors for a product, then said product can be found by filtering on either Red or Green or both.
Translation of values
Since every index corresponds to a specific language, the system will automatically handle translation of multilingual user-defined fields. Therefore, if you have configured a user-defined field to be multilingual, the appropriate translation will be automatically available in each index. This makes the system highly flexible without requiring additional index configuration.
Last updated
Was this helpful?