Skip to main content
This page documents an earlier version of the API client. For the latest version, see Search for rules.
Required ACL: settings

Examples

index.SearchRules( new RuleQuery("query")
  {
    Anchoring = "is",
    Context = "something",
    Page = 1,
    HitsPerPage = 10
  }
);

// Asynchronous
await index.SearchRulesAsync( new RuleQuery("query")
  {
    Anchoring = "is",
    Context = "something",
    Page = 1,
    HitsPerPage = 10
  }
);

Parameters

anchoring
enum<string>
When specified, restricts matches to rules with a specific anchoring type. When omitted, all anchoring types may match. One of:
  • contains
  • endsWith
  • is
  • startsWith
context
string
Restricts matches to contextual rules with a specific context (exact match).
enabled
boolean
When specified, restricts matches to rules with a specific enabled status. When absent (default), all rules are retrieved, regardless of their enabled status.
hitsPerPage
integer
default:20
Maximum number of hits in a page. Minimum is 1, maximum is 1000.
page
integer
default:0
Requested page (zero-based).
query
string
Search query
requestOptions
object
A mapping of request options to send along with the request.

Response

hits
object[]
Rule objects matched by the search query (see rule). Highlighting is provided through the standard mechanism (_highlightResult attribute inside every returned object)
nbHits
integer
Total number of rules matching the query.
nbPages
integer
Total number of pages.
page
integer
Returned page number (zero-based).

Response as JSON

This section shows the JSON response returned by the API. Each API client wraps this response in language-specific objects, so the structure may vary. To view the response, use the getLogs method. Don’t rely on the order of properties—JSON objects don’t preserve key order.
JSON
{
  "hits":[
    {
      "conditions":[{
        "pattern":"smartphone",
        "anchoring":"contains"
      }],
      "consequence":{
        "params":{
          "filters":"category = 1"
        }
      },
      "objectID":"a-rule-id",
      "_highlightResult":{
        "conditions":[{
          "pattern":{
            "value":"<b>s<\/b>martphone",
            "matchLevel":"full",
            "fullyHighlighted":false,
            "matchedWords":[
              "s"
            ]
          }],
          "anchoring":{
            "value":"contains",
            "matchLevel":"none",
            "matchedWords":[

            ]
          }
        },
        "consequence":{
          "params":{
            "filters":{
              "value":"category = 1",
              "matchLevel":"none",
              "matchedWords":[

              ]
            }
          }
        }
      }
    }
  ],
  "nbHits":1,
  "page":0,
  "nbPages":1
}
I