Merchandising rules
Rules let you decide what some searches show: put the new collection first for “summer”, hide a discontinued product, push your own brand up for “running shoes”, or show a sale banner on every search this weekend.
A rule
Section titled “A rule”{ "id": "summer-launch", "description": "Summer collection first", "pattern": "summer", "match": "contains", "lang": "en", "validFrom": "2026-06-01T00:00:00Z", "validUntil": "2026-08-31T23:59:59Z", "pins": [{ "id": "dress-301-en", "position": 1 }, { "id": "hat-12-en", "position": 2 }], "hides": ["dress-099-en"], "boosts": [{ "filters": { "categories": ["Summer 2026"] }, "factor": 3 }], "banner": { "title": "Summer sale", "text": "Up to 40% off swimwear", "imageUrl": "https://example.com/img/summer.jpg", "linkUrl": "https://example.com/summer" }}When a rule matches
Section titled “When a rule matches”| Field | Notes |
|---|---|
pattern |
The words to match. Empty ("") only when match is any. |
match |
is (the whole query), contains (the words anywhere in the query), starts_with, or any (every query). Defaults to is. |
lang |
Only searches in this language. |
contexts |
Only searches that send one of these in ruleContexts. See Contexts. |
validFrom, validUntil |
Only between these times (ISO 8601). |
enabled |
false keeps the rule without applying it. |
Matching ignores case, Arabic letter variants and the Arabic article (ال), and
works on whole words: contains with
“shoe” matches “red shoe sale” but not “shoelaces”. Every rule that matches
applies, in the order of the list.
What a rule does
Section titled “What a rule does”| Field | Does |
|---|---|
pins |
Puts records at fixed positions (1 to 100), whatever their relevance. |
hides |
Removes records from the results. |
filters |
Adds filters, such as only in-stock items for “gift”. |
replaceQuery |
Searches for something else instead, such as a common misspelling or an old product name. |
boosts |
Multiplies the scores of results that match the filters by factor (1 to 100, default 2). |
buries |
Divides the scores of results that match the filters by factor. |
banner |
A banner to show above the results: title, and optionally text, imageUrl and linkUrl. |
userData |
Any JSON (up to 8 KB) returned with the results, for your own UI. |
The search response says what applied:
{ "hits": [ /* … */ ], "appliedRules": ["summer-launch"], "banners": [{ "title": "Summer sale", "text": "Up to 40% off swimwear", "linkUrl": "https://example.com/summer" }], "userData": [{ "layout": "lookbook" }]}The widget shows banners for you. With your own UI, render banners and use
userData however you like.
Contexts
Section titled “Contexts”Contexts limit a rule to searches made in a certain place: the mobile app, a
sale page, a members’ area. Give the rule contexts, and send the matching
ruleContexts with the search:
{ "pattern": "", "match": "any", "contexts": ["sale-page"], "filters": { "categories": ["Sale"] } }{ "q": "dress", "ruleContexts": ["sale-page"] }A rule without contexts applies to every search. Searches can send up to 10
contexts. In the widget, set ruleContexts, or data-rule-contexts on a results
block.
Manage rules
Section titled “Manage rules”In the dashboard, open the app’s Rules page, then try your rules in the Search preview, which can send rule contexts too. Or replace the whole list through the API:
curl -s -X PUT "https://api.shoofai.co/v1/apps/$SHOOF_APP/rules" \ -H "x-shoof-api-key: $SHOOF_ADMIN_KEY" -H "content-type: application/json" \ -d @rules.jsonPUT replaces every rule, so send the full list. GET /rules returns it.
Limits
Section titled “Limits”Every plan includes up to 1,000 rules per app. Saving more is refused with
402 quota_exceeded.
After a downgrade, every rule stays stored, but only the first enabled rules, up
to the new limit, apply.