curl \
-X PATCH 'MEILISEARCH_URL/dynamic-search-rules/black-friday' \
-H 'Authorization: Bearer API_KEY' \
-H 'Content-Type: application/json' \
--data-binary '{
"description": "Black Friday 2025 rules",
"precedence": 10,
"active": true,
"conditions": {
"query": {
"isEmpty": true
},
"time": {
"start": "2025-11-28T00:00:00Z",
"end": "2025-11-28T23:59:59Z"
}
},
"actions": {
"pin": [
{
"indexUid": "products",
"id": "123",
"position": 1
}
]
}
}'client.updateDynamicSearchRule('RULE_UID', {
description: 'Promote billing help for invoice searches',
precedence: 1,
active: true,
conditions: {
query: { words: 'invoice' }
},
actions: {
pin: [{ id: '299537', position: 0, indexUid: 'movies' }]
}
})$client->updateDynamicSearchRule(
(new \Meilisearch\Contracts\UpdateDynamicSearchRuleQuery('RULE_UID'))
->setActions([
'pin' => [
[
'id' => '299537',
'position' => 0,
'indexUid' => 'movies'
]
]
])
);client.update_dynamic_search_rule('black-friday', {
'description': 'Black Friday 2025 rules',
'precedence': 10,
'active': True,
'conditions': {
'query': {'isEmpty': True},
'time': {
'start': '2025-11-28T00:00:00Z',
'end': '2025-11-28T23:59:59Z'
}
},
'actions': {
'pin': [
{'indexUid': 'products', 'id': '123', 'position': 1}
]
}
})Map<String, Object> conditions = Map.of(
"query", Map.of("isEmpty", true),
"time", Map.of("start", "2025-11-28T00:00:00Z", "end", "2025-11-28T23:59:59Z"));
List<Map<String, Object>> actions = List.of(
Map.of(
"selector", Map.of("indexUid", "products", "id", "123"),
"action", Map.of("type", "pin", "position", 1)));
DynamicSearchRule rule = new DynamicSearchRule(
"black-friday", "Black Friday 2025 rules", 10, true, conditions, actions);
TaskInfo task = client.updateDynamicSearchRule("black-friday", rule);active := true
isEmpty := true
startTime, _ := time.Parse(time.RFC3339, "2025-11-28T00:00:00Z")
endTime, _ := time.Parse(time.RFC3339, "2025-11-28T23:59:59Z")
client.UpdateSearchRule("black-friday", &meilisearch.SearchRulesRequest{
Description: "Black Friday 2025 rules",
Priority: 10,
Active: &active,
Conditions: &meilisearch.Conditions{
Query: &meilisearch.QueryCondition{
IsEmpty: &isEmpty,
},
Time: &meilisearch.TimeCondition{
Start: &startTime,
End: &endTime,
},
},
Actions: []meilisearch.Action{
{
Selector: meilisearch.Selector{
IndexUid: "products",
ID: "123",
},
Action: meilisearch.ActionDef{
Type: "pin",
Position: 1,
},
},
},
})var patchQuery = new PatchDynamicSearchRule
{
Description = "Promote billing help for invoice searches",
Precedence = 1,
Active = true,
Conditions = new DynamicSearchRuleConditions
{
Query = new QueryCondition { Words = "invoice" }
},
Actions = new DSRActions
{
Pin = new[]
{
new DSRPin { Id = "299537", Position = 0, IndexUid = "movies" }
}
}
};
await client.CreateOrUpdateDynamicSearchRuleAsync("RULE_UID", patchQuery);require 'uri'
require 'net/http'
url = URI("http://localhost:7700/dynamic-search-rules/{uid}")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"description\": \"<string>\",\n \"precedence\": 1,\n \"active\": true,\n \"conditions\": {\n \"time\": {\n \"start\": \"2023-11-07T05:31:56Z\",\n \"end\": \"2023-11-07T05:31:56Z\"\n },\n \"query\": {\n \"isEmpty\": true,\n \"words\": \"<string>\"\n },\n \"filter\": {\n \"values\": {}\n }\n },\n \"actions\": {\n \"pin\": [\n {\n \"id\": \"<string>\",\n \"position\": 1,\n \"indexUid\": \"<string>\"\n }\n ],\n \"scale\": [\n {\n \"weight\": 123,\n \"indexUid\": \"<string>\",\n \"ids\": [\n \"<string>\"\n ],\n \"filter\": \"<unknown>\"\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"taskUid": 147,
"indexUid": null,
"status": "enqueued",
"type": "dsrUpdate",
"enqueuedAt": "2024-08-08T17:05:55.791772Z"
}{
"message": "The Authorization header is missing. It must use the bearer authorization method.",
"code": "missing_authorization_header",
"type": "auth",
"link": "https://docs.meilisearch.com/errors#missing_authorization_header"
}Create or update a search rule
Partially update a search rule by replacing the provided fields. If the rule doesn’t exist, it will be created.
curl \
-X PATCH 'MEILISEARCH_URL/dynamic-search-rules/black-friday' \
-H 'Authorization: Bearer API_KEY' \
-H 'Content-Type: application/json' \
--data-binary '{
"description": "Black Friday 2025 rules",
"precedence": 10,
"active": true,
"conditions": {
"query": {
"isEmpty": true
},
"time": {
"start": "2025-11-28T00:00:00Z",
"end": "2025-11-28T23:59:59Z"
}
},
"actions": {
"pin": [
{
"indexUid": "products",
"id": "123",
"position": 1
}
]
}
}'client.updateDynamicSearchRule('RULE_UID', {
description: 'Promote billing help for invoice searches',
precedence: 1,
active: true,
conditions: {
query: { words: 'invoice' }
},
actions: {
pin: [{ id: '299537', position: 0, indexUid: 'movies' }]
}
})$client->updateDynamicSearchRule(
(new \Meilisearch\Contracts\UpdateDynamicSearchRuleQuery('RULE_UID'))
->setActions([
'pin' => [
[
'id' => '299537',
'position' => 0,
'indexUid' => 'movies'
]
]
])
);client.update_dynamic_search_rule('black-friday', {
'description': 'Black Friday 2025 rules',
'precedence': 10,
'active': True,
'conditions': {
'query': {'isEmpty': True},
'time': {
'start': '2025-11-28T00:00:00Z',
'end': '2025-11-28T23:59:59Z'
}
},
'actions': {
'pin': [
{'indexUid': 'products', 'id': '123', 'position': 1}
]
}
})Map<String, Object> conditions = Map.of(
"query", Map.of("isEmpty", true),
"time", Map.of("start", "2025-11-28T00:00:00Z", "end", "2025-11-28T23:59:59Z"));
List<Map<String, Object>> actions = List.of(
Map.of(
"selector", Map.of("indexUid", "products", "id", "123"),
"action", Map.of("type", "pin", "position", 1)));
DynamicSearchRule rule = new DynamicSearchRule(
"black-friday", "Black Friday 2025 rules", 10, true, conditions, actions);
TaskInfo task = client.updateDynamicSearchRule("black-friday", rule);active := true
isEmpty := true
startTime, _ := time.Parse(time.RFC3339, "2025-11-28T00:00:00Z")
endTime, _ := time.Parse(time.RFC3339, "2025-11-28T23:59:59Z")
client.UpdateSearchRule("black-friday", &meilisearch.SearchRulesRequest{
Description: "Black Friday 2025 rules",
Priority: 10,
Active: &active,
Conditions: &meilisearch.Conditions{
Query: &meilisearch.QueryCondition{
IsEmpty: &isEmpty,
},
Time: &meilisearch.TimeCondition{
Start: &startTime,
End: &endTime,
},
},
Actions: []meilisearch.Action{
{
Selector: meilisearch.Selector{
IndexUid: "products",
ID: "123",
},
Action: meilisearch.ActionDef{
Type: "pin",
Position: 1,
},
},
},
})var patchQuery = new PatchDynamicSearchRule
{
Description = "Promote billing help for invoice searches",
Precedence = 1,
Active = true,
Conditions = new DynamicSearchRuleConditions
{
Query = new QueryCondition { Words = "invoice" }
},
Actions = new DSRActions
{
Pin = new[]
{
new DSRPin { Id = "299537", Position = 0, IndexUid = "movies" }
}
}
};
await client.CreateOrUpdateDynamicSearchRuleAsync("RULE_UID", patchQuery);require 'uri'
require 'net/http'
url = URI("http://localhost:7700/dynamic-search-rules/{uid}")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"description\": \"<string>\",\n \"precedence\": 1,\n \"active\": true,\n \"conditions\": {\n \"time\": {\n \"start\": \"2023-11-07T05:31:56Z\",\n \"end\": \"2023-11-07T05:31:56Z\"\n },\n \"query\": {\n \"isEmpty\": true,\n \"words\": \"<string>\"\n },\n \"filter\": {\n \"values\": {}\n }\n },\n \"actions\": {\n \"pin\": [\n {\n \"id\": \"<string>\",\n \"position\": 1,\n \"indexUid\": \"<string>\"\n }\n ],\n \"scale\": [\n {\n \"weight\": 123,\n \"indexUid\": \"<string>\",\n \"ids\": [\n \"<string>\"\n ],\n \"filter\": \"<unknown>\"\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"taskUid": 147,
"indexUid": null,
"status": "enqueued",
"type": "dsrUpdate",
"enqueuedAt": "2024-08-08T17:05:55.791772Z"
}{
"message": "The Authorization header is missing. It must use the bearer authorization method.",
"code": "missing_authorization_header",
"type": "auth",
"link": "https://docs.meilisearch.com/errors#missing_authorization_header"
}Authorizations
An API key is a token that you provide when making API calls. Read more about how to secure your project.
Include the API key to the Authorization header, for instance:
-H 'Authorization: Bearer 6436fc5237b0d6e0d64253fbaac21d135012ecf1'
If you use a SDK, ensure you instantiate the client with the API key, for instance with JS SDK:
const client = new MeiliSearch({
host: 'MEILISEARCH_URL',
apiKey: '6436fc5237b0d6e0d64253fbaac21d135012ecf1'
});
Body
Precedence of the dynamic search rule. Lower numeric values take precedence over higher ones. If omitted, the rule is treated as having the lowest precedence. This precedence is used to resolve conflicts between matching rules:
- If the same document is selected by multiple rules, the smallest
prioritynumber wins - If different documents are pinned to the same position, they are ordered by ascending
priority
x >= 0Response
Task enqueued to update dynamic search rule.
A summarized view of a task, returned when a task is enqueued
Type of operation performed by the task.
documentAdditionOrUpdate, documentEdition, documentDeletion, settingsUpdate, indexCreation, indexDeletion, indexUpdate, indexSwap, taskCancelation, taskDeletion, dumpCreation, snapshotCreation, export, upgradeDatabase, indexCompaction, networkTopologyChange, dsrUpdate, dsrClear "documentAdditionOrUpdate"