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.

OperationEndpoint
SearchPOST https://{TENANT_ID}-search.kelp.click/api/v1/collections/{collection}/search
BrowsePOST 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

FieldTypeApplies toNotes
qstringsearchThe query term. Omit for browse. Must not exceed 512 characters or 50 words (backend-enforced).
semanticWeightstringsearchOptional 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.
distinctBystringbothOptional. One hit per distinct value of that field (for example, styleId returns one hit per keyedTags.styleId).
pagenumberboth1-based page number.
perPagenumberbothResults per page.
sortSortItem[]both{ field, direction: "asc" | "desc" }. Multiple items apply in order.
fieldsstring[]bothField projection - return only these document fields.
filtersKelpFilter[]bothFilter clauses (see below).
facetsstring[]bothFields to return facet counts for.
userId / sessionIdstringbothIdentity for personalization and attribution.
personalizebooleanbothOpt 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..."
}
FieldTypeNotes
hitsKelpHit[]Each hit has document (your fields) and highlights ({ field, snippet }, snippets may contain <mark> tags).
facetCountsKelpFacetCount[]{ field, counts: [{ value, count }] } for each requested facet.
foundnumberTotal matching documents.
pagenumberThe page returned (1-based).
processingTimeMsnumberServer processing time.
queryIdstringCorrelate later click/conversion events back to this query. See Events.

Hits are already merchandised when rules exist in Kelp. See Merchandising.

On this page