Search & browse
Query and list documents in a Kelp collection, with filters, facets, sorting, and pagination.
Search and browse share one request and response shape. Use search when you have a query term (q); use browse for filtered listing with no query.
| Operation | Endpoint |
|---|---|
| Search | POST https://{TENANT_ID}-search.kelp.click/api/v1/collections/{collection}/search |
| Browse | POST https://{TENANT_ID}-search.kelp.click/api/v1/collections/{collection}/browse |
Request
Headers on every call: Content-Type: application/json and X-Api-Key: <key>.
Body fields
| Field | Type | Applies to | Notes |
|---|---|---|---|
q | string | search | The query term. Omit for browse. Must not exceed 512 characters or 50 words (backend-enforced). |
semanticWeight | string | search | Optional semantic blend: strict | heavy | default | balanced | light | keyword | off. Omit or unset = keyword-only. Semantic ranking only when the collection has enableSemanticSearch and this field is sent. Do not send on browse. See Semantic search. |
distinctBy | string | both | Optional. One hit per distinct value of that field (for example, styleId returns one hit per keyedTags.styleId). |
page | number | both | 1-based page number. |
perPage | number | both | Results per page. |
sort | SortItem[] | both | { field, direction: "asc" | "desc" }. Multiple items apply in order. |
fields | string[] | both | Field projection - return only these document fields. |
filters | KelpFilter[] | both | Filter clauses (see below). |
facets | string[] | both | Fields to return facet counts for. |
userId / sessionId | string | both | Identity for personalization and attribution. |
personalize | boolean | both | Opt into per-request personalization. |
Filters
A filter clause is { "field": string, "op"?: string, "values": string[] }. op defaults to =. Operators: =, !=, >, >=, <, <=, range (where values is [min, max]). See Filtering & Facets.
Example
curl -X POST https://acme-search.kelp.click/api/v1/collections/products/search \
-H "Content-Type: application/json" \
-H "X-Api-Key: kelp_pk_..." \
-d '{
"q": "sunglasses",
"page": 1,
"perPage": 20,
"fields": ["id", "title", "handle", "minPrice"],
"filters": [{ "field": "brand", "op": "=", "values": ["globex"] }],
"sort": [{ "field": "minPrice", "direction": "asc" }],
"facets": ["brand"]
}'Semantic search (search only)
Omit semanticWeight for keyword-only ranking. Send a named weight on search when the collection has enableSemanticSearch and you want a meaning blend.
curl -X POST https://acme-search.kelp.click/api/v1/collections/products/search \
-H "Content-Type: application/json" \
-H "X-Api-Key: kelp_pk_..." \
-d '{
"q": "shoes that can be used in water",
"semanticWeight": "default",
"page": 1,
"perPage": 20,
"filters": [{ "field": "status", "op": "=", "values": ["ACTIVE"] }]
}'Do not include semanticWeight on browse requests. Browse stays filter-and-sort.
Response
{
"hits": [
{
"document": { "id": "1", "objectId": "1", "title": "Aviator sunglasses", "handle": "aviator", "minPrice": 4900 },
"highlights": [{ "field": "title", "snippet": "Aviator <mark>sunglasses</mark>" }]
}
],
"facetCounts": [
{ "field": "brand", "counts": [{ "value": "globex", "count": 12 }] }
],
"found": 42,
"page": 1,
"processingTimeMs": 7,
"queryId": "q_9f3a..."
}| Field | Type | Notes |
|---|---|---|
hits | KelpHit[] | Each hit has document (your fields) and highlights ({ field, snippet }, snippets may contain <mark> tags). |
facetCounts | KelpFacetCount[] | { field, counts: [{ value, count }] } for each requested facet. |
found | number | Total matching documents. |
page | number | The page returned (1-based). |
processingTimeMs | number | Server processing time. |
queryId | string | Correlate later click/conversion events back to this query. See Events. |
Hits are already merchandised when rules exist in Kelp. See Merchandising.