|
| 1 | +--- |
| 2 | +title: Search rule patterns |
| 3 | +sidebarTitle: Pinning patterns |
| 4 | +description: Task-oriented guides for common search rule patterns such as query-based pinning, empty-query curation, and scheduled promotions. |
| 5 | +--- |
| 6 | + |
| 7 | +All create and update examples on this page use `PATCH /dynamic-search-rules/{uid}`. The `uid` comes from the path, and omitted fields remain unchanged when you update an existing rule. |
| 8 | + |
| 9 | +## How do I pin one result for a query? |
| 10 | + |
| 11 | +Pin a document whenever the query contains a specific substring: |
| 12 | + |
| 13 | +```json |
| 14 | +{ |
| 15 | + "description": "Promote billing help for invoice searches", |
| 16 | + "active": true, |
| 17 | + "conditions": [ |
| 18 | + { "scope": "query", "contains": "invoice" } |
| 19 | + ], |
| 20 | + "actions": [ |
| 21 | + { |
| 22 | + "selector": { "indexUid": "support", "id": "billing-workspace-overview" }, |
| 23 | + "action": { "type": "pin", "position": 0 } |
| 24 | + } |
| 25 | + ] |
| 26 | +} |
| 27 | +``` |
| 28 | + |
| 29 | +Use this pattern when you want to promote a landing page, help article, or campaign document for a specific query family. |
| 30 | + |
| 31 | +## How do I pin several results in a fixed order? |
| 32 | + |
| 33 | +Add multiple actions with explicit positions: |
| 34 | + |
| 35 | +```json |
| 36 | +{ |
| 37 | + "description": "Show billing resources first for invoice searches", |
| 38 | + "active": true, |
| 39 | + "conditions": [ |
| 40 | + { "scope": "query", "contains": "invoice" } |
| 41 | + ], |
| 42 | + "actions": [ |
| 43 | + { |
| 44 | + "selector": { "indexUid": "support", "id": "billing-workspace-overview" }, |
| 45 | + "action": { "type": "pin", "position": 0 } |
| 46 | + }, |
| 47 | + { |
| 48 | + "selector": { "indexUid": "support", "id": "download-monthly-statements" }, |
| 49 | + "action": { "type": "pin", "position": 1 } |
| 50 | + } |
| 51 | + ] |
| 52 | +} |
| 53 | +``` |
| 54 | + |
| 55 | +This keeps the pinned documents in a predictable order while leaving the rest of the hits in their normal organic order. |
| 56 | + |
| 57 | +## How do I curate the default results for an empty query? |
| 58 | + |
| 59 | +Use the `isEmpty` query condition to curate the browse state when users search with an empty query: |
| 60 | + |
| 61 | +```json |
| 62 | +{ |
| 63 | + "description": "Curate the default help-center browse state", |
| 64 | + "active": true, |
| 65 | + "conditions": [ |
| 66 | + { "scope": "query", "isEmpty": true } |
| 67 | + ], |
| 68 | + "actions": [ |
| 69 | + { |
| 70 | + "selector": { "indexUid": "support", "id": "quickstart-overview" }, |
| 71 | + "action": { "type": "pin", "position": 0 } |
| 72 | + } |
| 73 | + ] |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +This is useful when users often start by browsing instead of typing a search. |
| 78 | + |
| 79 | +## How do I schedule a promotion for a limited time? |
| 80 | + |
| 81 | +Combine a query condition with a time condition: |
| 82 | + |
| 83 | +```json |
| 84 | +{ |
| 85 | + "description": "Promote seasonal content during a campaign window", |
| 86 | + "active": true, |
| 87 | + "conditions": [ |
| 88 | + { "scope": "query", "contains": "summer sale" }, |
| 89 | + { "scope": "time", "start": "2026-06-01T00:00:00Z", "end": "2026-06-30T23:59:59Z" } |
| 90 | + ], |
| 91 | + "actions": [ |
| 92 | + { |
| 93 | + "selector": { "indexUid": "products", "id": "summer-sale-landing-page" }, |
| 94 | + "action": { "type": "pin", "position": 0 } |
| 95 | + } |
| 96 | + ] |
| 97 | +} |
| 98 | +``` |
| 99 | + |
| 100 | +Multiple conditions are combined with `AND`, so this rule only applies during the campaign window and only when the query contains `summer sale`. |
| 101 | + |
| 102 | +## How do I list active rules or rules with similar UIDs? |
| 103 | + |
| 104 | +Use `POST /dynamic-search-rules` with pagination and filters: |
| 105 | + |
| 106 | +```json |
| 107 | +{ |
| 108 | + "offset": 0, |
| 109 | + "limit": 20, |
| 110 | + "filter": { |
| 111 | + "attributePatterns": ["promo*"], |
| 112 | + "active": true |
| 113 | + } |
| 114 | +} |
| 115 | +``` |
| 116 | + |
| 117 | +`attributePatterns` uses attribute-pattern syntax, for example `promo*`. |
| 118 | + |
| 119 | +## How do I pause a rule without deleting it? |
| 120 | + |
| 121 | +Set `active` to `false`: |
| 122 | + |
| 123 | +```json |
| 124 | +{ |
| 125 | + "active": false |
| 126 | +} |
| 127 | +``` |
| 128 | + |
| 129 | +Use `DELETE /dynamic-search-rules/{uid}` only when you want to remove the rule entirely. |
0 commit comments