Search & browse

Ranking

How Kelp ranks results - relevance tiers in search, popularity and sort in browse, merchandising, and ranking field configuration.

Kelp uses a two-phase ranking model that differs between search (query-driven) and browse (filter-and-sort-driven). Understanding which mode you are in - and how ranking fields interact with sort - helps you configure collections that order results the way you want.

Search: relevance tiers with ranking field blending

When you call search with a text query, results are first grouped into relevance tiers:

  1. Exact match - title or primary fields contain the query verbatim
  2. Strong match - high token overlap across searchable fields
  3. Partial match - weaker signal (stemming, partial tokens)

Within each tier, ranking fields (configured on the collection) re-order results. A product with a higher trending score beats a product with a lower score when both sit in the same relevance tier.

This means ranking fields never override relevance: a poorly matching result with a high bestSeller score will not outrank a highly relevant product. They only break ties within the same tier.

Tier 1 (exact):   [trending: 850, trending: 420, trending: 210]
Tier 2 (strong):  [trending: 1200, trending: 400]
Tier 3 (partial): [trending: 90]

A product in Tier 2 with trending: 1200 still ranks below all Tier 1 results.

Merchandising applies after this tier model. Pins, boosts, buries, and hides are set in Kelp and change order for every shopper on that query.

Semantic search vs keyword

When the collection has enableSemanticSearch and the search request sends semanticWeight, Kelp blends meaning match with keyword match before the rest of ranking. Heavier weights favor products that match the shopper's intent even when the title does not share those words. Lighter weights stay closer to keyword ranking.

Omit semanticWeight and search stays keyword-only - the collection flag alone does not change ranking. browse has no semantic weight; it stays sort-and-filter.

See Semantic search for the named weights (strict through off) and request examples.

Browse: sort order, ranking signals, and missing values

browse has no query - results are ordered purely by the configured sort and ranking signals.

Missing values sort last

When a sort or ranking field is applied in browse mode, products that are missing a value for that field sort to the end of the result set. This is the correct behavior for popularity sorting: products with no order history (bestSeller: 0, trending: 0) appear after products with real scores.

// Products with trending > 0 appear first; products with no order data sort last.
await kelp.browse('products', {
  sort: [{ field: 'trending', direction: 'desc' }],
});

Products with bestSeller: 0 or trending: 0 are not missing - they have an explicit zero. "Missing" means the field is absent from the document entirely, which can happen during the window between a product being created in Shopify and the next order sync completing.

Ranking configuration

Configure ranking fields on a collection to control which signals blend within relevance tiers (search) or influence default order (browse). Reference a field in the collection's ranking config:

{
  "ranking": ["trending", "bestSeller"]
}

Fields are applied in order - trending has more weight than bestSeller in the example above.

Any field listed in ranking must also be a sortable catalog field. The catalog fields reference lists which fields are rankable.

Popularity fields

The two popularity fields are the primary candidates for ranking and sort:

FieldDescriptionSource
bestSellerAll-time units sold since tracking beganShopify order history via order sync
trendingUnits sold in the trailing 60 daysShopify order history via order sync

Both are updated daily by the automatic order sync and can be refreshed on demand. See Catalog sync (Shopify) for how popularity is computed.

Using popularity in collection ranking

{
  "ranking": ["trending"]
}

With this config:

  • In search, trending score breaks ties within each relevance tier
  • In browse (no explicit sort), trending score drives the default order

Sorting directly on popularity

Sort on bestSeller or trending to surface the most popular products regardless of relevance tier:

// Browse: all-time best sellers first
await kelp.browse('products', {
  sort: [{ field: 'bestSeller', direction: 'desc' }],
  filters: [{ field: 'status', op: '=', values: ['ACTIVE'] }],
});

// Browse: trending this week, tie-break by all-time
await kelp.browse('products', {
  sort: [
    { field: 'trending',   direction: 'desc' },
    { field: 'bestSeller', direction: 'desc' },
  ],
});

When you supply an explicit sort array, it overrides the collection's default ranking order.

Interaction with sort and merchandising

ModeOrder of precedence
Search, no sortRelevance tier -> ranking fields -> personalisation (beta) -> merchandising
Search, with sortSort field(s) -> within sort group: relevance tier -> ranking fields -> personalisation (beta) -> merchandising
Browse, no sortCollection ranking config -> missing values last -> personalisation (beta) -> merchandising
Browse, with sortSort field(s) -> missing values last -> personalisation (beta) -> merchandising

Merchandising (pin, boost, bury, hide) is last and wins. Rules are set in Kelp and apply to every shopper on that query or listing.

Catalogue personalisation is beta. Pass userId, sessionId, and personalize when you want a per-shopper reorder. First visits and SEO should use the standard order (personalize omitted or false).

On this page