Sorting
Providing users with relevant sorting options enables them to find more relevant results. Sorting in Ecommerce Search is configurable on a segment-by-segment basis. Before any sortings can be applied, they must first be added as Allowed sortings.
Text fields will always be sorted alphabetically, while number fields will be sorted according to numerical value.
Sort order
The sorting order can be either:
Order | Effect |
---|---|
desc |
Descending sorting order (Default) |
asc |
Ascending sorting order |
Sorting on predefined fields
Ecommerce Search provides a number of default fields on products/SKUs and content. These fields can be sorted using the following sort keys
Available sorting options for products are:
Key | Explanation |
---|---|
name |
SKU name |
score |
Relevance score |
price |
Price |
savings |
Discount of SKU in selected price group |
skuid |
ID of SKU |
productid |
ID of product |
Available sorting options for content are:
Key | Explanation |
---|---|
score |
Relevance score |
id |
Content ID |
Sorting on attributes
StringAttributes and NumberAttributes defined on SKUs, Products or Content are sortable by their defined attribute key. Note that sort keys are case sensitive.
Sorting by a StringAttribute field
Given the SKU:
SKU | |
---|---|
Result can be sorted on the 'Color' attribute using the following request:
Default sort
If no sorting field is specified Ecommerce Search defaults to sorting search results based on the score field in descending order. Ecommerce Search will also revert to the default when given invalid sorting fields in search queries.
Tiebreakers
Ecommerce Search will apply a tiebreaker sorting, when two or more hits have the same ranking in the search result.
The tiebreakers are the ProductId for product results and ContentId for content results.
Multiple sortings
Multiple sorting fields can be applied to search results. When using more than one sorting the specified sorting fields will be applied in the order they are given.
Example
The following request will sort the search results by the 'color' field first and use the 'name' field as a tiebreaker. In case a tie still exists the default tiebreaker will be applied.