Search relevance answers the question “which products match this query?” Business ranking answers a different question: “which matching products should appear first for this store?” In WooCommerce, custom ranking lets an agency apply that second layer consistently across product listings without hard-coding product IDs or manually reordering every result.
What custom ranking does in Algolia
Algolia’s customRanking setting adds business-oriented ranking criteria after the main textual relevance criteria. It is most useful when several products are similarly relevant to a query and the store needs a predictable tie-breaker.
Custom ranking criteria are evaluated in the order in which they are configured. For example, the following configuration prioritizes featured products, then popularity, then profit margin:
customRanking: [
"desc(is_featured)",
"desc(popularity_score)",
"desc(margin_score)"
]
With this configuration, a product with is_featured: 1 ranks ahead of a product with is_featured: 0 when the earlier relevance criteria do not separate them. Among products with the same featured value, the product with the higher popularity score comes first.
Prepare WooCommerce data for ranking
Do not rank directly on presentation labels such as “Featured” or “Best Seller.” Export stable, numeric attributes that represent the ranking policy. A typical product record might include:
{
"objectID": "8421",
"name": "Trail Running Shoes",
"is_featured": 1,
"popularity_score": 874,
"margin_score": 62,
"inventory_priority": 3,
"stock_status": "instock"
}
Useful attributes for WooCommerce catalogs include:
- is_featured: a binary value such as
1or0, sourced from the product’s featured status. - popularity_score: a normalized score based on recent sales, add-to-cart events, or product views.
- margin_score: a controlled commercial score rather than raw cost data that should not be exposed to customers.
- inventory_priority: a value that supports stock-aware merchandising, such as a higher score for products with healthy inventory.
- launch_score: a temporary or decaying score for new products.
Keep the values numeric and consistently populated. Missing, null, or incorrectly formatted values can make the result order difficult to explain and may prevent the intended criterion from working reliably.
Configure the index settings
Apply the setting to the Algolia index used by the relevant WooCommerce search experience. The exact index name depends on the integration, environment, and whether the store has separate indices for products, suggestions, or locales.
const settings = {
customRanking: [
'desc(is_featured)',
'desc(popularity_score)',
'desc(inventory_priority)'
]
};
await index.setSettings(settings);
Use desc when a larger value should rank first and asc when a smaller value should rank first. For example, asc(price) favors lower prices, while desc(popularity_score) favors more popular products.
Custom ranking is index-level configuration. If a store needs different ranking policies for different experiences, create separate indices or replicas rather than trying to make one fixed ranking rule serve every context.
Choose scores that reflect the business goal
A common mistake is to place a raw WooCommerce sales count directly into ranking. That can cause older products to dominate indefinitely and can make a short-term campaign ineffective. A better approach is to calculate a score before indexing.
For example, an agency could combine recent performance and inventory availability in an external catalog pipeline:
popularity_score =
(sales_last_30_days * 10) +
(add_to_carts_last_30_days * 3) +
(views_last_30_days * 1)
The calculation should be documented, bounded where appropriate, and recalculated on a schedule that matches the store’s sales volume. High-volume stores may update popularity several times per day. Smaller catalogs may only need a daily update.
If margin is part of the ranking policy, consider using a banded score such as 1 through 5 rather than indexing the exact margin. This reduces sensitivity to small fluctuations and gives merchandising teams a manageable control.
Handle featured products carefully
A binary featured flag is easy to understand, but putting it first in every query can over-promote a small set of products. It can also make search results feel less relevant when the featured products only loosely match the query.
Before making is_featured the first custom criterion, test queries across important product groups. In some stores, a better order is:
customRanking: [
"desc(popularity_score)",
"desc(is_featured)",
"desc(inventory_priority)"
]
This keeps popular matching products ahead while still using the featured flag to break ties. The right order depends on the merchandising policy and should be validated with real search terms rather than judged from one query.
Use replicas for customer-selected sorting
Custom ranking is appropriate for a default business order. It is not the right mechanism for every sort option shown in a WooCommerce storefront.
If shoppers can choose “Price: low to high,” “Price: high to low,” or “Newest,” configure Algolia replicas for those alternatives. A replica can use a different ranking formula while sharing the source index’s records and searchable configuration.
- Use the primary index for the default relevance and merchandising order.
- Use a price-ascending replica for low-to-high price sorting.
- Use a price-descending replica for high-to-low price sorting.
- Use a date-descending replica for newest products.
This separates a fixed business preference from an explicit customer sorting choice. The storefront should switch indices when the shopper changes the sort control.
Keep ranking fields synchronized
Ranking quality depends on the freshness of the attributes, not only on the index settings. A WooCommerce agency should define when each field is recalculated and which events trigger an update.
- Update
is_featuredwhen a product’s featured status changes. - Update inventory-related fields after stock or backorder changes.
- Recalculate popularity on a scheduled job or analytics pipeline.
- Reindex products after pricing, category, or campaign changes that affect merchandising.
- Use partial updates where appropriate, while ensuring every record retains valid ranking attributes.
Do not rely solely on a browser-side ranking adjustment. The ranking policy should live in Algolia’s index settings so search, autocomplete, and server-rendered requests produce the same order.
Test the ranking with a controlled query set
Create a test set that represents the store’s important search behavior: exact product names, category terms, generic terms, misspellings, branded terms, and queries with many matching products. For each query, record the expected product group and inspect whether the ranking fields produce the intended tie-breaks.
Also test edge cases such as products with missing scores, out-of-stock products, newly launched products, and products with unusually high historical sales. If stock availability must be enforced rather than merely encouraged, use a filter or separate inventory policy instead of relying only on custom ranking.
For agencies, keep the ranking configuration and score definitions in version control. Record the reason for each criterion, its direction, its data source, and the update frequency. This makes ranking changes auditable and prevents a future catalog import from silently removing the fields on which the index depends.