Curation

Curation sets let you hand-tune results for specific queries: pin documents to fixed positions, hide documents, inject filters, override sorting, or replace the query entirely. Rules can match by query text, filter, tags, and time windows.

Create a Curation Set

PUT /curation_sets/promotions
Content-Type: application/json
X-TYPESENSE-API-KEY: YOUR_API_KEY

{
  "items": [
    {
      "id": "featured-laptop",
      "rule": {"query": "laptop", "match": "exact"},
      "includes": [{"id": "prod-42", "position": 1}],
      "excludes": [{"id": "prod-13"}]
    }
  ]
}

Bind to a Collection

Collections reference curation sets in their schema - every search on the collection evaluates the bound sets:

{
  "name": "products",
  "curation_sets": ["promotions"],
  "fields": [ ... ]
}

Rules

A rule decides when an item applies:

FieldDescription
query + matchMatch the search's q: exact or contains. "query": "*" matches every query.
filter_byApplies when the search's filter_by parameter equals this exactly
tagsApplies when the search passes a matching curation_tags parameter

Item Actions

FieldDescription
includesPin documents to 1-based positions: [{"id": "doc1", "position": 1}]
excludesHide documents from the results entirely
filter_byExtra filter AND-ed onto the search's filter
sort_byOverride the search's sort order
replace_queryReplace the query text before searching
remove_matched_tokensStrip the rule's tokens from the query
filter_curated_hitsWhen true, pinned documents must also satisfy the search's filter_by
stop_processingStop evaluating further items after this one matches (default true)
effective_from_ts / effective_to_tsUnix-timestamp window during which the item is active - schedule promotions ahead of time
metadataArbitrary JSON echoed in the search response when the item matches

Search Parameters

ParameterDescription
curation_tagsComma-separated tags - only items whose rule tags match are evaluated
enable_curations=falseSkip curation evaluation for this query
filter_curated_hitsPer-query override of the item-level setting

Curation applies in both single search and multi-search. Pinned documents surface in grouped results at the pinned position.

API Reference

# Sets
GET    /curation_sets                    # list all sets
PUT    /curation_sets/{name}             # create or replace a set
GET    /curation_sets/{name}             # get a set
DELETE /curation_sets/{name}             # delete a set

# Items within a set
GET    /curation_sets/{name}/items       # list items
PUT    /curation_sets/{name}/items/{id}  # create or update an item
GET    /curation_sets/{name}/items/{id}  # get an item
DELETE /curation_sets/{name}/items/{id}  # delete an item