Skip to main content
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}'
{
  "hits": [
    {
      "objectID": "<string>",
      "conditions": [
        {
          "pattern": "{facet:genre}",
          "anchoring": "is",
          "alternatives": false,
          "context": "mobile",
          "filters": "genre:comedy"
        }
      ],
      "consequence": {
        "params": {
          "similarQuery": "comedy drama crime Macy Buscemi",
          "filters": "(category:Book OR category:Ebook) AND _tags:published",
          "facetFilters": [
            [
              "category:Book",
              "category:-Movie"
            ],
            "author:John Doe"
          ],
          "optionalFilters": [
            "category:Book",
            "author:John Doe"
          ],
          "numericFilters": [
            [
              "inStock = 1",
              "deliveryDate < 1441755506"
            ],
            "price < 1000"
          ],
          "tagFilters": [
            [
              "Book",
              "Movie"
            ],
            "SciFi"
          ],
          "sumOrFiltersScores": false,
          "restrictSearchableAttributes": [
            "title",
            "author"
          ],
          "facets": [
            "*"
          ],
          "facetingAfterDistinct": false,
          "page": 0,
          "offset": 123,
          "length": 500,
          "aroundLatLng": "40.71,-74.01",
          "aroundLatLngViaIP": false,
          "aroundRadius": 2,
          "aroundPrecision": 123,
          "minimumAroundRadius": 2,
          "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
            ]
          ],
          "naturalLanguages": [],
          "ruleContexts": [
            "mobile"
          ],
          "personalizationImpact": 100,
          "userToken": "test-user-123",
          "getRankingInfo": false,
          "synonyms": true,
          "clickAnalytics": false,
          "analytics": true,
          "analyticsTags": [],
          "percentileComputation": true,
          "enableABTest": true,
          "attributesToRetrieve": [
            "author",
            "title",
            "content"
          ],
          "ranking": [
            "typo",
            "geo",
            "words",
            "filters",
            "proximity",
            "attribute",
            "exact",
            "custom"
          ],
          "relevancyStrictness": 90,
          "attributesToHighlight": [
            "author",
            "title",
            "conten",
            "content"
          ],
          "attributesToSnippet": [
            "content:80",
            "description"
          ],
          "highlightPreTag": "<em>",
          "highlightPostTag": "</em>",
          "snippetEllipsisText": "…",
          "restrictHighlightAndSnippetArrays": false,
          "hitsPerPage": 20,
          "minWordSizefor1Typo": 4,
          "minWordSizefor2Typos": 8,
          "typoTolerance": true,
          "allowTyposOnNumericTokens": true,
          "disableTypoToleranceOnAttributes": [
            "sku"
          ],
          "ignorePlurals": [
            "ca",
            "es"
          ],
          "removeStopWords": [
            "ca",
            "es"
          ],
          "queryLanguages": [
            "es"
          ],
          "decompoundQuery": true,
          "enableRules": true,
          "enablePersonalization": false,
          "queryType": "prefixLast",
          "removeWordsIfNoResults": "firstWords",
          "mode": "keywordSearch",
          "semanticSearch": {
            "eventSources": [
              "<string>"
            ]
          },
          "advancedSyntax": false,
          "optionalWords": "<string>",
          "disableExactOnAttributes": [
            "description"
          ],
          "exactOnSingleWordQuery": "attribute",
          "alternativesAsExact": [
            "ignorePlurals",
            "singleWordSynonym"
          ],
          "advancedSyntaxFeatures": [
            "exactPhrase",
            "excludeWords"
          ],
          "distinct": 1,
          "replaceSynonymsInHighlight": false,
          "minProximity": 1,
          "responseFields": [
            "*"
          ],
          "maxValuesPerFacet": 100,
          "sortFacetValuesBy": "count",
          "attributeCriteriaComputedByMinProximity": false,
          "renderingContent": {
            "facetOrdering": {
              "facets": {
                "order": "<any>"
              },
              "values": {}
            },
            "redirect": {
              "url": "<string>"
            },
            "widgets": {
              "banners": [
                "<any>"
              ]
            }
          },
          "enableReRanking": true,
          "reRankingApplyFilter": [
            "<any>"
          ],
          "query": {
            "remove": [
              "<string>"
            ],
            "edits": [
              {
                "type": "remove",
                "delete": "<string>",
                "insert": "<string>"
              }
            ]
          },
          "automaticFacetFilters": [
            {
              "facet": "<string>",
              "score": 123,
              "disjunctive": true
            }
          ],
          "automaticOptionalFacetFilters": [
            {
              "facet": "<string>",
              "score": 123,
              "disjunctive": true
            }
          ]
        },
        "promote": [
          {
            "objectIDs": [
              "test-record-123"
            ],
            "position": 0
          }
        ],
        "filterPromotes": false,
        "hide": [
          {
            "objectID": "test-record-123"
          }
        ],
        "userData": {
          "settingID": "f2a7b51e3503acc6a39b3784ffb84300",
          "pluginVersion": "1.6.0"
        }
      },
      "description": "Display a promotional banner",
      "enabled": true,
      "validity": [
        {
          "from": 123,
          "until": 123
        }
      ]
    }
  ],
  "nbHits": 123,
  "page": 123,
  "nbPages": 123
}
Required ACL: settings

Authorizations

x-algolia-application-id
string
header
required

Your Algolia application ID.

x-algolia-api-key
string
header
required

Your Algolia API key with the necessary permissions to make the request. Permissions are controlled through access control lists (ACL) and access restrictions. The required ACL to make a request is listed in each endpoint's reference.

Path Parameters

indexName
string
required

Name of the index on which to perform the operation.

Example:

"ALGOLIA_INDEX_NAME"

Body

application/json

Rules search parameters.

query
string
default:""

Search query for rules.

anchoring
enum<string>

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
context
string

Only return rules that match the context (exact match).

Example:

"mobile"

page
integer

Requested 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 is page=0, the second is page=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 >= 0
hitsPerPage
integer
default:20

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 is page=0, the second is page=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 <= 1000
enabled
boolean | null

If true, return only enabled rules. If false, return only inactive rules. By default, all rules are returned.

Response

OK

hits
object[]
required

Rules that matched the search criteria.

nbHits
integer
required

Number of rules that matched the search criteria.

page
integer
required

Current page.

nbPages
integer
required

Number of pages.

I