Custom Sorting

Custom sorting allows you to select in which order the result elements from a query will be displayed.

By default, Doofinder arranges searched products based on their relevance, determined by the score assigned by Doofinder's algorithm. This score is a numerical value assigned to each search result, reflecting how closely it aligns with the search criteria. Results are sorted by this score, with the highest-scoring results appearing first.

However, there may be situations where multiple results have identical scores, and the search results do not align with your desired criteria. In such cases, the Custom Sorting feature becomes invaluable. It allows you to define the sequence in which search results should display products.

Please note that altering the Custom Sorting section may impact other configured Business rules, such as Dynamic Re-ranking and Custom Results. Therefore, it is advisable to keep 'SCORE Descending' as the primary rule. This ensures the search engine functions correctly, prioritizing the most relevant products.

In the event that you've configured custom sorting, and the results are not as expected, you can easily reset this functionality and make adjustments as needed.

Custom Sorting Fields

In addition to the SCORE field, you can use other attribute fields such as price, sales quantity, availability, stock, etc. to set the display order of your results. Sorting can be done in ascending or descending order, either for numerical or alphabetical values.

Numerical values:

  • Ascending order goes from 0 > 99999 and descending order goes from 99999 > 0

Alphabetical values:

  • An ascending alphabetical order sorts the text by the first letter of the first word, with «A» first and «Z» last.

How to Configure Custom Sorting

To access the Custom sorting feature in your Admin Panel, go to: Search Engines > Settings > Custom Sorting.

Configure the plugin

Next, pick a field from the dropdown menu and specify the desired order, whether ascending or descending. Afterward, click the '+Add' button, and finally, save your settings by clicking the button located at the bottom right of the screen.

Configure the plugin

The maximum number of fields recommended for sorting is five attributes, but for best search results, refrain from removing the score field from the first position.

The order in which the fields are placed is the order in which the sorting will be executed during the searches. For example, in the case that a product is tied by score, the following custom sorting criteria will be applied to sort that product. And so on with the list of configured fields.

Therefore, it is advisable to always leave SCORE descending in the first position and not to remove it from the admin. When you add a new field, it will automatically be placed in the first position. So you have to rearrange the order by dragging and dropping them directly to put the SCORE back to the top of the list.

Configure the plugin

Remember you can always reset the fields as often as you want by clicking the reset option on the left. To delete a field, click on the trash icon on the right side of the screen.

When to Use Custom Sorting

Suppose you have products with the same search score. With Doofinder's Custom Sorting feature, you can specify more than one sort criteria from the drop-down list to add to SCORE. In this example, we will choose the "price" field and then determine the sort order, either descending or ascending. Once the sorting preferences have been set, simply click the "Save" button to apply them. This method ensures that the initial sorting criterion is based on 'Score' and, in the event of a tie, the 'price' criterion is used to sort the results.

Configure the plugin

Another use case is to apply the Availability field. When the sort fields are text fields, the sorting is done alphabetically, which is not always the best. But the exception is the availability field because it usually contains only two values: in stock and out of stock, so in this case Doofinder can sort alphabetically with ease.

This is a special case in which the score field can be placed in the second position of the list in descending order, and the availability field in ascending order in first position, so that the results that will be displayed first will be those with availability IN STOCK, sorted by score, followed by the results OUT OF STOCK, also sorted by score.

Configure the plugin

🗒 Note: You can always reset the fields as often as you want. Custom Sorting is not the same as Custom Results.