API Reference / API Methods / Rules / Replace all rules
Required API Key: any key with the editSettings ACL
Method signature
index.replace_all_rules(Array rules)

index.replace_all_rules(Array rules, Hash opts = {
  'forwardToReplicas': Boolean
})

About this method # A

You’re currently reading the Ruby API client v2 documentation. Check the migration guide to learn how to upgrade from v1 to v2. You can still access the v1 documentation.

Push a new set of rules and erase all previous ones.

This method, like replaceAllObjects, guarantees zero downtime.

All existing rules are deleted and replaced with the new ones, in a single, atomic operation.

Examples # A

Replace all rules#

1
2
3
4
5
6
7
8
9
client = Algolia::Search::Client.create('AJ0P3S7DWQ', '••••••••••••••••••••')

rules = [] # Fetch your rules

index = client.init_index('your_index_name')
index.replace_all_rules(rules)

# Or if you want to also replace rules on replicas
index.replace_all_rules(rules, {'forwardToReplicas': true})

Parameters # A

rules #
type: list
Required

See rule.

forwardToReplicas #
type: boolean
default: false
Optional

Also replace rules on replicas

requestOptions #
type: key/value mapping
default: No request options
Optional

A mapping of requestOptions to send along with the request.

Response # A

No response

Did you find this page helpful?
Ruby v2