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.
search | browse | |
|---|---|---|
| When to use | Search box, autocomplete, query-driven results | Collection pages, category listings, no user query |
q param | Required (non-empty string) | Not accepted |
semanticWeight | Optional. Semantic meaning blend when the collection flag is on and a weight is sent; omit = keyword-only | Not accepted - no semantic dial |
distinctBy | Optional. One hit per distinct value of a field | Optional. Same |
| Ranking | Relevance tiers first; ranking fields blend results within each tier; then personalization | Sort order drives order; ranking fields apply within sort groups; products missing a ranked field sort last |
| Filters | Supported | Supported |
| Sort | Supported | Supported |
| Facet counts | Supported | Supported |
search
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;qis required and must be non-empty.opts.signal- anAbortSignalto 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 asSearchParamsminusqandsemanticWeight).distinctByis onBrowseParams.opts.signal- anAbortSignalto 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.