🎉 Try the public beta of the new docs site at algolia.com/doc-beta! 🎉
API client / Methods / Rules
Required API Key: any key with the editSettings ACL
Method signature
$index->replaceAllRules(array rules);
$index->replaceAllRules(array rules, [
  'forwardToReplicas' => boolean
]);

We released a new version of the PHP API client in public beta. Read the beta documentation for more information.

About this method # A

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
10
11
12
$client = Algolia\AlgoliaSearch\SearchClient::create(
  'AJ0P3S7DWQ',
  '••••••••••••••••••••'
);

$rules = /* Fetch your rules */;

$index = $client->initIndex('your_index_name');
$index->replaceAllRules($rules);

// Or if you want to also replace rules on replicas
$index->replaceAllRules($rules, ['forwardToReplicas' => true]);

Parameters # A

Parameter Description
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

This method doesn't return a response.

Did you find this page helpful?
PHP v3