curl
curl --request POST \
--url https://algolia_application_id.algolia.net/1/indexes/ALGOLIA_INDEX_NAME/rules/search \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '
{
"query": "",
"anchoring": "is",
"context": "mobile",
"page": 0,
"hitsPerPage": 20,
"enabled": true
}
'// Initialize the client
var client = new SearchClient(new SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.SearchRulesAsync(
"<YOUR_INDEX_NAME>",
new SearchRulesParams { Query = "zorro" }
);
// print the response
Console.WriteLine(response);// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.searchRules(
indexName: "<YOUR_INDEX_NAME>",
searchRulesParams: SearchRulesParams(
query: "zorro",
),
);
// print the response
print(response);// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.SearchRules(client.NewApiSearchRulesRequest(
"<YOUR_INDEX_NAME>").WithSearchRulesParams(
search.NewEmptySearchRulesParams().SetQuery("zorro")))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY");
// Call the API
SearchRulesResponse response = client.searchRules("<YOUR_INDEX_NAME>", new SearchRulesParams().setQuery("zorro"));
// print the response
System.out.println(response);// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY');
// Call the API
const response = await client.searchRules({ indexName: 'cts_e2e_browse', searchRulesParams: { query: 'zorro' } });
// print the response
console.log(response);// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey = "ALGOLIA_API_KEY")
// Call the API
var response =
client.searchRules(
indexName = "<YOUR_INDEX_NAME>",
searchRulesParams = SearchRulesParams(query = "zorro"),
)
// print the response
println(response)// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY');
// Call the API
$response = $client->searchRules(
'<YOUR_INDEX_NAME>',
['query' => 'zorro',
],
);
// print the response
var_dump($response);# Initialize the client
# In an asynchronous context, you can use SearchClient instead, which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
# Call the API
response = client.search_rules(
index_name="<YOUR_INDEX_NAME>",
search_rules_params={
"query": "zorro",
},
)
# print the response
print(response)# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
# Call the API
response = client.search_rules("<YOUR_INDEX_NAME>", Algolia::Search::SearchRulesParams.new(query: "zorro"))
# print the response
puts(response)// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey = "ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.searchRules(
indexName = "<YOUR_INDEX_NAME>",
searchRulesParams = Some(
SearchRulesParams(
query = Some("zorro")
)
)
),
Duration(100, "sec")
)
// print the response
println(response)// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID", apiKey: "ALGOLIA_API_KEY")
// Call the API
let response = try await client.searchRules(
indexName: "<YOUR_INDEX_NAME>",
searchRulesParams: SearchRulesParams(query: "zorro")
)
// print the response
print(response){
"hits": [
{
"consequence": {
"filterPromotes": false,
"hide": [
{
"objectID": "test-record-123"
}
],
"params": {
"advancedSyntax": false,
"advancedSyntaxFeatures": [
"exactPhrase",
"excludeWords"
],
"allowTyposOnNumericTokens": true,
"alternativesAsExact": [
"ignorePlurals",
"singleWordSynonym"
],
"analytics": true,
"analyticsTags": [],
"aroundLatLng": "40.71,-74.01",
"aroundLatLngViaIP": false,
"aroundPrecision": 10,
"aroundRadius": 2,
"attributeCriteriaComputedBy": "best",
"attributeCriteriaComputedByMinProximity": false,
"attributesToHighlight": [
"author",
"title",
"conten",
"content"
],
"attributesToRetrieve": [
"author",
"title",
"content"
],
"attributesToSnippet": [
"content:80",
"description"
],
"automaticFacetFilters": [
{
"facet": "<string>",
"disjunctive": false,
"score": 1
}
],
"automaticOptionalFacetFilters": [
{
"facet": "<string>",
"disjunctive": false,
"score": 1
}
],
"clickAnalytics": false,
"decompoundQuery": true,
"disableExactOnAttributes": [
"description"
],
"disableTypoToleranceOnAttributes": [
"sku"
],
"distinct": 1,
"enableABTest": true,
"enablePersonalization": false,
"enableReRanking": true,
"enableRules": true,
"exactOnSingleWordQuery": "attribute",
"facetFilters": [
[
"category:Book",
"category:-Movie"
],
"author:John Doe"
],
"facetingAfterDistinct": false,
"facets": [
"*"
],
"filters": "(category:Book OR category:Ebook) AND _tags:published",
"getRankingInfo": false,
"highlightPostTag": "</em>",
"highlightPreTag": "<em>",
"hitsPerPage": 20,
"ignorePlurals": [
"ca",
"es"
],
"insideBoundingBox": "<string>",
"insidePolygon": [
[
47.3165,
4.9665,
47.3424,
5.0201,
47.32,
4.9
],
[
40.9234,
2.1185,
38.643,
1.9916,
39.2587,
2.0104
]
],
"length": 500,
"maxValuesPerFacet": 100,
"minimumAroundRadius": 2,
"minProximity": 1,
"minWordSizefor1Typo": 4,
"minWordSizefor2Typos": 8,
"mode": "keywordSearch",
"naturalLanguages": [],
"numericFilters": [
[
"inStock = 1",
"deliveryDate < 1441755506"
],
"price < 1000"
],
"offset": 123,
"optionalFilters": [
"category:Book",
"author:John Doe"
],
"optionalWords": "<string>",
"page": 0,
"percentileComputation": true,
"personalizationImpact": 100,
"query": {
"edits": [
{
"delete": "<string>",
"insert": "<string>",
"type": "remove"
}
],
"remove": [
"<string>"
]
},
"queryLanguages": [
"es"
],
"queryType": "prefixLast",
"ranking": [
"typo",
"geo",
"words",
"filters",
"proximity",
"attribute",
"exact",
"custom"
],
"relevancyStrictness": 90,
"removeStopWords": [
"ca",
"es"
],
"removeWordsIfNoResults": "firstWords",
"renderingContent": {
"facetOrdering": {
"facets": {
"order": [
"<string>"
]
},
"values": {}
},
"redirect": {
"url": "<string>"
},
"widgets": {
"banners": [
{
"image": {
"title": "<string>",
"urls": [
{
"url": "<string>"
}
]
},
"link": {
"url": "<string>"
}
}
],
"resultCard": {
"enabled": true
}
}
},
"replaceSynonymsInHighlight": false,
"reRankingApplyFilter": [
"<unknown>"
],
"responseFields": [
"*"
],
"restrictHighlightAndSnippetArrays": false,
"restrictSearchableAttributes": [
"title",
"author"
],
"ruleContexts": [
"mobile"
],
"semanticSearch": {
"eventSources": [
"<string>"
]
},
"similarQuery": "comedy drama crime Macy Buscemi",
"snippetEllipsisText": "…",
"sortFacetValuesBy": "count",
"sumOrFiltersScores": false,
"synonyms": true,
"tagFilters": [
[
"Book",
"Movie"
],
"SciFi"
],
"typoTolerance": true,
"userToken": "test-user-123"
},
"promote": [
{
"objectIDs": [
"test-record-123"
],
"position": 0
}
],
"redirect": {
"indexName": "<string>"
},
"userData": {
"settingID": "f2a7b51e3503acc6a39b3784ffb84300",
"pluginVersion": "1.6.0"
}
},
"objectID": "<string>",
"condition": {
"alternatives": false,
"anchoring": "is",
"context": "mobile",
"filters": "genre:comedy",
"pattern": "{facet:genre}"
},
"conditions": [
{
"alternatives": false,
"anchoring": "is",
"context": "mobile",
"filters": "genre:comedy",
"pattern": "{facet:genre}"
}
],
"description": "Display a promotional banner",
"enabled": true,
"scope": "<string>",
"tags": [
"<string>"
],
"validity": [
{
"from": 123,
"until": 123
}
]
}
],
"nbHits": 123,
"nbPages": 123,
"page": 123
}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}Rules
Search for rules
Searches for rules in your index.
POST
/
1
/
indexes
/
{indexName}
/
rules
/
search
curl
curl --request POST \
--url https://algolia_application_id.algolia.net/1/indexes/ALGOLIA_INDEX_NAME/rules/search \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '
{
"query": "",
"anchoring": "is",
"context": "mobile",
"page": 0,
"hitsPerPage": 20,
"enabled": true
}
'// Initialize the client
var client = new SearchClient(new SearchConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY"));
// Call the API
var response = await client.SearchRulesAsync(
"<YOUR_INDEX_NAME>",
new SearchRulesParams { Query = "zorro" }
);
// print the response
Console.WriteLine(response);// Initialize the client
final client =
SearchClient(appId: 'ALGOLIA_APPLICATION_ID', apiKey: 'ALGOLIA_API_KEY');
// Call the API
final response = await client.searchRules(
indexName: "<YOUR_INDEX_NAME>",
searchRulesParams: SearchRulesParams(
query: "zorro",
),
);
// print the response
print(response);// Initialize the client
client, err := search.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.SearchRules(client.NewApiSearchRulesRequest(
"<YOUR_INDEX_NAME>").WithSearchRulesParams(
search.NewEmptySearchRulesParams().SetQuery("zorro")))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)// Initialize the client
SearchClient client = new SearchClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY");
// Call the API
SearchRulesResponse response = client.searchRules("<YOUR_INDEX_NAME>", new SearchRulesParams().setQuery("zorro"));
// print the response
System.out.println(response);// Initialize the client
const client = algoliasearch('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY');
// Call the API
const response = await client.searchRules({ indexName: 'cts_e2e_browse', searchRulesParams: { query: 'zorro' } });
// print the response
console.log(response);// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey = "ALGOLIA_API_KEY")
// Call the API
var response =
client.searchRules(
indexName = "<YOUR_INDEX_NAME>",
searchRulesParams = SearchRulesParams(query = "zorro"),
)
// print the response
println(response)// Initialize the client
$client = SearchClient::create('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY');
// Call the API
$response = $client->searchRules(
'<YOUR_INDEX_NAME>',
['query' => 'zorro',
],
);
// print the response
var_dump($response);# Initialize the client
# In an asynchronous context, you can use SearchClient instead, which exposes the exact same methods.
client = SearchClientSync("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
# Call the API
response = client.search_rules(
index_name="<YOUR_INDEX_NAME>",
search_rules_params={
"query": "zorro",
},
)
# print the response
print(response)# Initialize the client
client = Algolia::SearchClient.create("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
# Call the API
response = client.search_rules("<YOUR_INDEX_NAME>", Algolia::Search::SearchRulesParams.new(query: "zorro"))
# print the response
puts(response)// Initialize the client
val client = SearchClient(appId = "ALGOLIA_APPLICATION_ID", apiKey = "ALGOLIA_API_KEY")
// Call the API
val response = Await.result(
client.searchRules(
indexName = "<YOUR_INDEX_NAME>",
searchRulesParams = Some(
SearchRulesParams(
query = Some("zorro")
)
)
),
Duration(100, "sec")
)
// print the response
println(response)// Initialize the client
let client = try SearchClient(appID: "ALGOLIA_APPLICATION_ID", apiKey: "ALGOLIA_API_KEY")
// Call the API
let response = try await client.searchRules(
indexName: "<YOUR_INDEX_NAME>",
searchRulesParams: SearchRulesParams(query: "zorro")
)
// print the response
print(response){
"hits": [
{
"consequence": {
"filterPromotes": false,
"hide": [
{
"objectID": "test-record-123"
}
],
"params": {
"advancedSyntax": false,
"advancedSyntaxFeatures": [
"exactPhrase",
"excludeWords"
],
"allowTyposOnNumericTokens": true,
"alternativesAsExact": [
"ignorePlurals",
"singleWordSynonym"
],
"analytics": true,
"analyticsTags": [],
"aroundLatLng": "40.71,-74.01",
"aroundLatLngViaIP": false,
"aroundPrecision": 10,
"aroundRadius": 2,
"attributeCriteriaComputedBy": "best",
"attributeCriteriaComputedByMinProximity": false,
"attributesToHighlight": [
"author",
"title",
"conten",
"content"
],
"attributesToRetrieve": [
"author",
"title",
"content"
],
"attributesToSnippet": [
"content:80",
"description"
],
"automaticFacetFilters": [
{
"facet": "<string>",
"disjunctive": false,
"score": 1
}
],
"automaticOptionalFacetFilters": [
{
"facet": "<string>",
"disjunctive": false,
"score": 1
}
],
"clickAnalytics": false,
"decompoundQuery": true,
"disableExactOnAttributes": [
"description"
],
"disableTypoToleranceOnAttributes": [
"sku"
],
"distinct": 1,
"enableABTest": true,
"enablePersonalization": false,
"enableReRanking": true,
"enableRules": true,
"exactOnSingleWordQuery": "attribute",
"facetFilters": [
[
"category:Book",
"category:-Movie"
],
"author:John Doe"
],
"facetingAfterDistinct": false,
"facets": [
"*"
],
"filters": "(category:Book OR category:Ebook) AND _tags:published",
"getRankingInfo": false,
"highlightPostTag": "</em>",
"highlightPreTag": "<em>",
"hitsPerPage": 20,
"ignorePlurals": [
"ca",
"es"
],
"insideBoundingBox": "<string>",
"insidePolygon": [
[
47.3165,
4.9665,
47.3424,
5.0201,
47.32,
4.9
],
[
40.9234,
2.1185,
38.643,
1.9916,
39.2587,
2.0104
]
],
"length": 500,
"maxValuesPerFacet": 100,
"minimumAroundRadius": 2,
"minProximity": 1,
"minWordSizefor1Typo": 4,
"minWordSizefor2Typos": 8,
"mode": "keywordSearch",
"naturalLanguages": [],
"numericFilters": [
[
"inStock = 1",
"deliveryDate < 1441755506"
],
"price < 1000"
],
"offset": 123,
"optionalFilters": [
"category:Book",
"author:John Doe"
],
"optionalWords": "<string>",
"page": 0,
"percentileComputation": true,
"personalizationImpact": 100,
"query": {
"edits": [
{
"delete": "<string>",
"insert": "<string>",
"type": "remove"
}
],
"remove": [
"<string>"
]
},
"queryLanguages": [
"es"
],
"queryType": "prefixLast",
"ranking": [
"typo",
"geo",
"words",
"filters",
"proximity",
"attribute",
"exact",
"custom"
],
"relevancyStrictness": 90,
"removeStopWords": [
"ca",
"es"
],
"removeWordsIfNoResults": "firstWords",
"renderingContent": {
"facetOrdering": {
"facets": {
"order": [
"<string>"
]
},
"values": {}
},
"redirect": {
"url": "<string>"
},
"widgets": {
"banners": [
{
"image": {
"title": "<string>",
"urls": [
{
"url": "<string>"
}
]
},
"link": {
"url": "<string>"
}
}
],
"resultCard": {
"enabled": true
}
}
},
"replaceSynonymsInHighlight": false,
"reRankingApplyFilter": [
"<unknown>"
],
"responseFields": [
"*"
],
"restrictHighlightAndSnippetArrays": false,
"restrictSearchableAttributes": [
"title",
"author"
],
"ruleContexts": [
"mobile"
],
"semanticSearch": {
"eventSources": [
"<string>"
]
},
"similarQuery": "comedy drama crime Macy Buscemi",
"snippetEllipsisText": "…",
"sortFacetValuesBy": "count",
"sumOrFiltersScores": false,
"synonyms": true,
"tagFilters": [
[
"Book",
"Movie"
],
"SciFi"
],
"typoTolerance": true,
"userToken": "test-user-123"
},
"promote": [
{
"objectIDs": [
"test-record-123"
],
"position": 0
}
],
"redirect": {
"indexName": "<string>"
},
"userData": {
"settingID": "f2a7b51e3503acc6a39b3784ffb84300",
"pluginVersion": "1.6.0"
}
},
"objectID": "<string>",
"condition": {
"alternatives": false,
"anchoring": "is",
"context": "mobile",
"filters": "genre:comedy",
"pattern": "{facet:genre}"
},
"conditions": [
{
"alternatives": false,
"anchoring": "is",
"context": "mobile",
"filters": "genre:comedy",
"pattern": "{facet:genre}"
}
],
"description": "Display a promotional banner",
"enabled": true,
"scope": "<string>",
"tags": [
"<string>"
],
"validity": [
{
"from": 123,
"until": 123
}
]
}
],
"nbHits": 123,
"nbPages": 123,
"page": 123
}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}Required ACL:
settingsAuthorizations
Path Parameters
Body
application/json
Rules search parameters.
Which part of the search query the pattern should match:
startsWith. The pattern must match the beginning of the query.endsWith. The pattern must match the end of the query.is. The pattern must match the query exactly.contains. The pattern must match anywhere in the query.
Empty queries are only allowed as patterns with anchoring: is.
Available options:
is, startsWith, endsWith, contains Maximum number of hits per page.
Algolia uses page and hitsPerPage to control how search results are displayed (paginated).
hitsPerPage: sets the number of search results (hits) displayed per page.page: specifies the page number of the search results you want to retrieve. Page numbering starts at 0, so the first page ispage=0, the second ispage=1, and so on.
For example, to display 10 results per page starting from the third page, set hitsPerPage to 10 and page to 2.
Required range:
1 <= x <= 1000Requested page of the API response.
Algolia uses page and hitsPerPage to control how search results are displayed (paginated).
hitsPerPage: sets the number of search results (hits) displayed per page.page: specifies the page number of the search results you want to retrieve. Page numbering starts at 0, so the first page ispage=0, the second ispage=1, and so on.
For example, to display 10 results per page starting from the third page, set hitsPerPage to 10 and page to 2.
Required range:
x >= 0Last modified on March 23, 2026
Was this page helpful?