Skip to main content

Sorting Search Results

Use the sort_by parameter to order search results by specified fields with optional tie-breaking. You can sort by up to 3 fields — if the first field has the same values, the second field is used to break the tie, and so on.

Sort Order

Append :asc or :desc to each field:

SuffixDirection
:ascAscending (A–Z, 0–9, low to high)
:descDescending (Z–A, 9–0, high to low)

Sortable Fields

Always sortable:

  • price.amount — product price as an integer amount
  • price.float_price — product price as a float
  • Any integer or float type indexable field

Conditionally sortable:

String fields can be enabled for sorting, but require additional indexing overhead.

caution

Enabling sorting on long string fields (for example, description) or in large datasets can significantly increase memory usage.

Examples

Single field:

price.amount:asc

Cheapest products first.

extensions.products(Specification).rating:desc

Highest rated first.

Multi-field tie-breaking:

price.amount:asc,extensions.products(Specification).rating:desc

Sorts by price (low to high), then by rating (high to low) for products with the same price.

Sorting Null, Empty, or Missing Values

Default behavior:

Field typeDefault placement of null/missing values
Numeric fieldsAlways placed at the end, regardless of sort order
String fields (ascending sort)Empty, null, or missing values placed at the end
String fields (descending sort)Empty, null, or missing values placed at the beginning

Overriding default behavior:

Use the missing_values parameter to control placement of null, empty, or missing values:

ValueBehavior
missing_values: firstPlaces null/empty/missing values at the beginning
missing_values: lastPlaces null/empty/missing values at the end

Examples:

sort_by=price.float_price(missing_values: first):asc

Products without a price appear first.

sort_by=price.float_price(missing_values: last):desc

Products without a price appear last.

Price Sorting in Segmented Catalogs

Products can have multiple prices across different price books. The price used for sorting depends on the catalog rule configuration:

Catalog typePrice used for sorting
Non-segmented catalogsDefault catalog prices
Segmented catalogs with 0 rule price booksDefault catalog prices
Segmented catalogs with 1 rule price bookThe price book's prices by default. Set force_use_default_price_for_faceting_and_sorting to true in the search profile to use default catalog prices instead.
Segmented catalogs with >=2 rule price booksDefault catalog prices
note

Products in a segmented catalog can have prices defined across many price books. The above limitations only apply to price books referenced in catalog rules.

Price sorting limitations

Sales prices are not supported. Only base prices are used for sorting.

Ask External AI