> ## Documentation Index
> Fetch the complete documentation index at: https://www.meilisearch.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Getting started with search rules

> Enable search rules, create your first rule, and verify how pinned results appear in search.

This guide walks you through enabling the experimental flag, creating your first rule, and checking how it affects search results. You can do this from the Meilisearch Cloud dashboard or directly against the API.

## Set up from the Meilisearch Cloud dashboard

Open your project in the [Meilisearch Cloud dashboard](https://cloud.meilisearch.com) and select the **Search rules** tab.

### Activate the feature

Search rules are an add-on. On the Search rules tab, click **Enable Search Rules** to turn on the `dynamicSearchRules` experimental flag for the project.

<img src="https://mintcdn.com/meilisearch-6b28dec2/UuxowY4mE7FIY7Tq/assets/images/cloud-search-rules/01-activate-addon.png?fit=max&auto=format&n=UuxowY4mE7FIY7Tq&q=85&s=6a0a0ec5cbf5d3eaa05b4710b5fe659d" alt="Meilisearch Cloud Search rules tab with an &#x22;Enable Search Rules&#x22; button in the add-on panel" width="3200" height="1954" data-path="assets/images/cloud-search-rules/01-activate-addon.png" />

### Create your first rule

Once the feature is active, the Search rules tab shows a short explainer and a **New rule** button. Click it to start building a rule.

<img src="https://mintcdn.com/meilisearch-6b28dec2/UuxowY4mE7FIY7Tq/assets/images/cloud-search-rules/02-create-first-rule.png?fit=max&auto=format&n=UuxowY4mE7FIY7Tq&q=85&s=efe99e972181af565d8526fb254aed53" alt="Search rules landing page with a &#x22;New rule&#x22; button in the top-right corner" width="3200" height="1954" data-path="assets/images/cloud-search-rules/02-create-first-rule.png" />

### Fill in the rule's general information

Give the rule a **Rule ID** (used as the `uid`), an optional **Description**, and a **Priority** if several rules might match the same query. Keep the **Active** toggle on to apply the rule at search time.

<img src="https://mintcdn.com/meilisearch-6b28dec2/UuxowY4mE7FIY7Tq/assets/images/cloud-search-rules/03-manage-rule.png?fit=max&auto=format&n=UuxowY4mE7FIY7Tq&q=85&s=cd3358865ad3baef9017c6c7bf5a67a8" alt="Rule editor showing Rule ID &#x22;summer-sales&#x22;, a description, priority 0, and General / Conditions / Actions sections" width="3200" height="1954" data-path="assets/images/cloud-search-rules/03-manage-rule.png" />

### Add conditions

In the **Conditions** block, click **Add condition** to open the condition dialog. Pick a type (**Query contains**, **Query is empty**, or **Time window**) and fill in the value. Every condition you add is combined with `AND`, so the rule fires only when all conditions are true at the same time.

<img src="https://mintcdn.com/meilisearch-6b28dec2/UuxowY4mE7FIY7Tq/assets/images/cloud-search-rules/04-add-condition.png?fit=max&auto=format&n=UuxowY4mE7FIY7Tq&q=85&s=4f9156184d96073bed48c3428bf68c7a" alt="Add condition dialog with a &#x22;Query contains&#x22; type and a &#x22;Contains substring&#x22; input" width="3200" height="1954" data-path="assets/images/cloud-search-rules/04-add-condition.png" />

### Pin documents to fixed positions

In the **Actions** block, click **Add pin**. Choose the source **Index**, pick the **Document** to promote, and set its target **Position** in the result list. Repeat for each document you want to pin. When the rule is ready, click **Create rule**.

<img src="https://mintcdn.com/meilisearch-6b28dec2/UuxowY4mE7FIY7Tq/assets/images/cloud-search-rules/05-add-pin.png?fit=max&auto=format&n=UuxowY4mE7FIY7Tq&q=85&s=8cbcffaf4b10a6f41c264049f9d2609e" alt="Add pin dialog with an index dropdown, a document selector, and a position input" width="3200" height="1954" data-path="assets/images/cloud-search-rules/05-add-pin.png" />

### Review and manage your rules

Back on the Search rules tab, every rule you have created is listed with its conditions, actions, priority, and active state. Use the row toggle to pause a rule without deleting it, or the icons on the right to edit or remove it.

<img src="https://mintcdn.com/meilisearch-6b28dec2/UuxowY4mE7FIY7Tq/assets/images/cloud-search-rules/06-rules-list.png?fit=max&auto=format&n=UuxowY4mE7FIY7Tq&q=85&s=b4d333f7f2c9ff3b97e79ce8f1c707c6" alt="Search rules list with one &#x22;summer-sales&#x22; rule showing its conditions, pin action, priority, and active toggle" width="3200" height="1954" data-path="assets/images/cloud-search-rules/06-rules-list.png" />

## Set up from the API

Prefer the API? The same flow maps directly to the `/dynamic-search-rules` routes.

### Enable the experimental flag

Send a `PATCH /experimental-features` to turn on the feature:

```json theme={null}
{
  "dynamicSearchRules": true
}
```

While the flag is disabled, the `/dynamic-search-rules` routes reject requests and saved rules do not apply at search time.

### Create a rule

Create a rule with `PATCH /dynamic-search-rules/invoice-help`:

```json theme={null}
{
  "description": "Promote billing help for invoice searches",
  "active": true,
  "conditions": [
    { "scope": "query", "contains": "invoice" }
  ],
  "actions": [
    {
      "selector": { "indexUid": "support", "id": "billing-workspace-overview" },
      "action": { "type": "pin", "position": 0 }
    }
  ]
}
```

This rule pins the document `billing-workspace-overview` in the `support` index to the first position whenever a query contains the substring `invoice`.

The route behaves as an upsert:

* It returns `201 Created` when the rule does not exist yet
* It returns `200 OK` when you update an existing rule

### Check the stored rule

Retrieve the rule you just created with `GET /dynamic-search-rules/invoice-help`. The response should include the `uid`, conditions, and actions you sent:

```json theme={null}
{
  "uid": "invoice-help",
  "description": "Promote billing help for invoice searches",
  "active": true,
  "conditions": [
    { "scope": "query", "contains": "invoice" }
  ],
  "actions": [
    {
      "selector": { "indexUid": "support", "id": "billing-workspace-overview" },
      "action": { "type": "pin", "position": 0 }
    }
  ]
}
```

### Run a matching search

Send a normal search request to the index, for example `POST /indexes/support/search`:

```json theme={null}
{
  "q": "invoice settings"
}
```

If `billing-workspace-overview` exists in the `support` index and survives the current filters, Meilisearch inserts it at position `0`. The rest of the response is the normal organic result set, with duplicates removed.

Search rules do not replace organic results. Meilisearch still computes them, then inserts the pinned documents on top.

## Next steps

<CardGroup cols={2}>
  <Card title="Pin one result for a query" href="/capabilities/search_rules/how_to/pin_one_result_for_query">
    Promote a landing page or help article for a query
  </Card>

  <Card title="Advanced" href="/capabilities/search_rules/advanced/pinning_behavior">
    Learn how search rules interact with ranking and filters
  </Card>

  <Card title="API reference" href="/reference/api/dynamic-search-rules/update-a-dynamic-search-rule-or-create-a-new-one-if-it-doesnt-exist">
    Review endpoints and request fields
  </Card>

  <Card title="Experimental features" href="/resources/help/experimental_features_overview">
    Learn more about experimental feature management
  </Card>
</CardGroup>
