Required API Key: any key with the settings ACL
Method signature
$index->getRule(objectID)
Method signature
index.get_rule(objectID)
Method signature
index.getRule(objectID, callback)
Method signature
index.read_rule(objectID)
Method signature
This method is not available in mobile API clients.

Query Rules need to be configured via
the Algolia Dashboard or with one of our backend API clients.

Method signature
This method is not available in mobile API clients.

Query Rules need to be configured via
the Algolia Dashboard or with one of our backend API clients.

Method signature
index.GetRule(objectID)
Method signature
index.getRule(objectID)
Method signature
index.GetRule(objectID)
Method signature
get.rule(objectID).from("index_name")

About this method

Get the object/definition of a specific rule.

Examples

<?php
$rule = $index->getRule('a-rule-id');
# Retrieve a rule by its unique ID.
index.get_rule('a-rule-id')
// Retrieve a rule by its unique ID.
index.getRule('a-rule-id', function(err, content) {
  if (err) throw err;

  console.log(content);
});
# Retrieve a rule by its unique ID.
index.get_rule('a-rule-id')
index.GetRule("a-rule-id");
// Sync version
Optional<Rule> rule = index.getRule());

// Async version
CompletableFuture<Optional<Rule>> rule = index.getRule();
rule, err := i.GetRule("a-rule-id")
val synonymRule: Future[Rule] = client.execute {
  get rule "a-rule-id" from "index_name"
}

Parameters

objectID
type: string
Required

The ID of the rule to retrieve.

Response

In this section we document the JSON response returned by the API. Each language will encapsulate this response inside objects specific to the language and/or the implementation. So the actual type in your language might differ from what is documented.

JSON format

{
  "objectID": "a-rule-id",
  "condition": {
    "pattern": "smartphone",
    "anchoring": "contains"
  },
  "consequence": {
    "params": {
      "filters": "category = 1"
    }
  }
}
objectID
string

objectID of the rule.

condition
list

Condition of the rule.

consequence
list

Consequence of the rule.

Php small white
PHP
Ruby small white
Ruby
Javascript small white
JavaScript
Python small white
Python
Swift small white
iOS
Android small white
Android
Csharp small white
C#
Java small white
Java
Go small white
Go
Scala small white
Scala
Php small white
PHP
Ruby small white
Ruby
Javascript small white
JavaScript
Python small white
Python
Swift small white
iOS
Android small white
Android
Csharp small white
C#
Java small white
Java
Go small white
Go
Scala small white
Scala