How Search Pipelet Sorting Rules Are Applied

The Search pipelet SortingRuleID parameter specifies the ID of the sorting rule to use to sort the products. You can also use the SortBy1, SortBy1Direction, SortBy2, SortBy2Direction, SortBy3, and SortBy3Direction attributes with explicit sorting attribute steps in sorting rules.

The Search pipelet uses the following rules to order search results:

  • If a SortingRuleID is specified and a valid rule exists with that ID, that rule is used.
  • If no SortingRuleID is specified or the specified ID is unknown or invalid, the default sorting rule for the search refining category is used.
  • If the default sorting rule for the category refined by is invalid or no default rule was set for the category, the inherited default rule of the parent category is used.
  • If the search isn't refined by category or there's no default rule set for any ancestor category, the default rule set for the root category of the storefront catalog is used.
  • If there is no default rule set for the root category, the products are sorted by the sort conditions set using SortByX parameters.
  • If no sorting rule applies, and no SortByX conditions are set, the products are sorted descending by text relevance based on the search term.
  • If no sorting rule applies, no SortByX conditions are set, and there is no search term, the products are not sorted in a particular order.

Example

The following is an example:

  1. A customer searches for jacket on the home page. The search results are sorted by the default rule set for the root category of the storefront catalog.
  2. The customer refines the search by category Men's. The refined results are sorted by the default rule set for the Men's category.
  3. The customer further refines the search by the Raincoats subcategory. Because no default rule is set for Raincoats, the refined results are sorted by the default rule set for the Men's category.
  4. The customer selects Sort by Price (Low-High) in a sorting options dropdown. The sorting rule ID for that sorting option is specified to the Search pipelet. The same refined results are now sorted by the rule with that ID.