Search & browse

Search vs Browse

When to use Kelp search (query-driven) vs browse (filter-and-sort-driven, no query term).

Kelp exposes two endpoints that look similar but serve different purposes. Both can return merchandised hits and a queryId.

searchbrowse
When to useSearch box, autocomplete, query-driven resultsCollection pages, category listings, no user query
q paramRequired (non-empty string)Not accepted
semanticWeightOptional. Semantic meaning blend when the collection flag is on and a weight is sent; omit = keyword-onlyNot accepted - no semantic dial
distinctByOptional. One hit per distinct value of a fieldOptional. Same
RankingRelevance tiers first; ranking fields blend results within each tier; then personalizationSort order drives order; ranking fields apply within sort groups; products missing a ranked field sort last
FiltersSupportedSupported
SortSupportedSupported
Facet countsSupportedSupported

Use search whenever there is a text query from the user. The backend ranks results by relevance to q and optionally re-ranks by personalization signals.

const res = await kelp.search('products', {
  q: 'sunglasses',
  perPage: 100,
  fields: ['id', 'title', 'handle'],
});

search(collection, params, opts?):

  • collection - the collection name, e.g. 'products'.
  • params - SearchParams; q is required and must be non-empty.
  • opts.signal - an AbortSignal to cancel the in-flight request.

In the React useSearch hook, an empty query string becomes "*" so the pane stays populated. When calling search directly, pass a non-empty q.

browse

Use browse for collection and category pages where there is no text query - results are driven purely by filters and sort order.

const res = await kelp.browse('products', {
  filters: [{ field: 'status', op: '=', values: ['ACTIVE'] }],
  sort: [{ field: 'variantsInStockPercentage', direction: 'desc' }],
  perPage: 10,
  fields: ['status'],
});

browse(collection, params, opts?):

  • collection - the collection name.
  • params - BrowseParams (same as SearchParams minus q and semanticWeight). distinctBy is on BrowseParams.
  • opts.signal - an AbortSignal to cancel the in-flight request.

Choosing the right one

User typed something in a search box?  -> search()
Rendering a /collections/:handle page? -> browse()
Showing all results with no input?     -> browse() (or search with q:"*")

Both methods accept identical filter, sort, facet, fields, personalization, and distinctBy params. q and semanticWeight are search-only. Merchandising applies on both without extra request fields. See Query parameters for the full reference.

On this page