How Sorting Rules Work

Sorting rules enable you to control the presentation of search results to the customer. You can use sorting rules to bring products to the attention of customers by having them appear at the top of search results. You can use any attribute to sort search results or a weighted blend of multiple attributes by creating dynamic attributes.

Order That Rules Are Applied and Breaking Ties

A sorting rule evaluates all products by the value in the top attribute in the sorting rule list. It breaks any ties in the values of the first attribute using the second attribute, then breaks any ties in the values of the first and second attributes using the values of the third attribute. This continues for all attributes used in sorting.

After all the sorting rules have been evaluated, products that are tied (or matched exactly) on all attributes, or have null values for the sort attributes, are sorted via the default sorting rules. These rules return products based on the search index document order, that is, the order in which the products are stored in the search index. Customers cannot control the index document order, and it can change from one release to another.
Note:

The values used in these examples are simplified.

Example:

This example demonstrates how products are sorted if you set up a sorting rule that first sort products by Search Placement, allowing a merchant to explicitly define items that they want to appear first. Products are then sorted by lowest return rate. Finally, products are sorted by highest sales velocity. Both of the latter attributes are active data attributes whose values are based on values aggregated in the storefront.

The following tables show how each rule is applied to sort products A-F based on their attribute values and the direction:

If you want to combine two attributes, rather than sort consecutively with them, this also changes the sorting. The following example shows a myRank dynamic attribute that combines searchRank and categoryPosition with a 50/50 weighting.

Direction

You can specify the order in which you want results sorted.
Note: For all data types, items with no value the field are placed last.
Data type Ascending Sort Descending Sort
String A-Z Z-A
Enum of String

Sorts on the value of the attribute, not the display value (1–100, A-Z). The sorting for multiple values is undefined.

In the example below the number is the value and the term in parentheses is the display value.

0010 (Winter)

0040 (Ankle)

Sorts on the value of the attribute, not the display value. (100-1, Z-A). The sorting for multiple values is undefined.

In the example below the number is the value and the term in parentheses is the display value.

0040 (Ankle)

0010 (Winter)

Date + Time 01/01/2001:12:01a - 12/30/2020: 11:59 p 12/30/2020: 11:59 p - 01/01/2001:12:01a
Boolean

1. products with value 'false'

2. products with value 'true'

1. products with value 'true'

2. products with value 'false'

Integer 1–100 100-1
Number 0.01 - 99.99 99.99 -.01
Date 01/01/2001- 12/30/2020 12/30/2020 - 01/01/2001
Enum of Integer 1–100 100-1

Inheritance

If a sorting rule isn't assigned to a category, the category inherits the sorting rule from its parent category. This inheritance goes all the way up to the root of the category structure - the catalog.

  • If you assign a sorting rule to the catalog and don't assign a sorting rule to any of its categories, the assigned sorting rule is inherited by all of the categories.
  • If you assign a sorting rule to a category within a catalog, it overrides the sorting rule that would have been inherited from one of its ancestor categories (parent category or above). Then this assigned category is inherited by all of its descendants (subcategories and below). In this way, you can affect large numbers of categories with just a few sorting rule assignments.

For simplicity and best performance, you should only assign a sorting rule when you want to change the sorting rule that would be inherited for a category and its subcategories. For example, assume that a catalog has top-level categories A, B, C, and D. If A and C should have rule 1, B should have rule 2, and D should have rule 3, then it's best to assign rule 1 to the catalog, rule 2 to B, and rule 3 to D. You would have the same results if you assigned rule 1 to A and C, but this is unnecessary.

If a subcategory of B named B1 should have rule 1, then you must assign rule 1 to that subcategory. This is because even though rule 1 is assigned to the catalog, B1 doesn't inherit rule 1 because rule 2 is assigned to its parent B. The assignment of rule 2 to B changes the rule that would have been inherited from the catalog. The assignment of rule 1 to B1 changes the rule that would have been inherited from B. This tree shows the sorting rules and their inheritance:

Catalog (rule 1 assigned)

  • category A (rule 1 inherited from catalog)
  • category B (rule 2 assigned, overrides rule 1 from catalog)
    • category B1 (rule 1 assigned, overrides rule 2 from category B)
  • category C (rule 1 inherited from catalog)
  • category D (rule 3 assigned, overrides rule 1 from catalog)

Variation Product Sorting Rules

When sorting base products, the highest or lowest value (depending on sort direction) of all the variation product is used when the base product has no value of its own. The value of the default variation product isn't preferred over others.

Sorting Product Sets

If a product set contains variation products, it's sorted based on the attributes defined in the variation products, unless the product set or the base product defines its own values for these attributes, such as for aggregated active data metrics.

Multi-Site Sorting Rules

Multi-Site Sorting Rules apply a sorting rule globally across all sites. Instead of having to apply the same sorting rule to each site individually, a multi-site rule can be used. It is important to note that global sorting rules can only use global dynamic attributes. Setting Sorting Rules or Dynamic Sorting Attributes to Global results in an instance-wide availability of the object (that is, the Sorting rule configuration). The actual sorting scores are still site-specific based on-site data.

You can change the rule context from individual site to global (and vice versa) in Business Manger or you can use the Import / Export functionality.
Note: To allow changing the context from β€œsite” for β€œglobal”, users must have the Manage_Global_Sorting_Rules setting (located at Business Manager > Administration > Organization > Roles & Permissions > user > Functional Permissions > Organization) set to true.

Category Sorting Rules

The sorting rule assigned to a storefront catalog's root category is used for category sorting. Sorting rule inheritance ensures that the root sorting rule is inherited by all subcategories of the catalog, if it's not overwritten on a subcategory level with another sorting rule.

The sorting rule applied to category-based search results is set for the root category of the navigational catalog. You can also select the category position standard attribute for a sorting rule if you want to place specific products in a particular order for a specific category.