Skip to main content
POST
/
1
/
indexes
/
{indexName}
/
{model}
/
recommend
/
rules
/
search
curl
curl --request POST \
  --url https://algolia_application_id.algolia.net/1/indexes/ALGOLIA_INDEX_NAME/related-products/recommend/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":"","context":"mobile","page":0,"hitsPerPage":20,"enabled":true,"filters":"objectID:rr-123456","facets":["*"],"maxValuesPerFacet":1}'
{
  "hits": [
    {
      "_metadata": {
        "lastUpdate": "2023-07-04T12:49:15Z"
      },
      "objectID": "<string>",
      "condition": {
        "filters": "(category:Book OR category:Ebook) AND _tags:published",
        "context": "mobile"
      },
      "consequence": {
        "hide": [
          {
            "objectID": "test-record-123"
          }
        ],
        "promote": [
          {
            "objectID": "test-record-123",
            "position": 1
          }
        ],
        "params": {
          "automaticFacetFilters": [
            {
              "facet": "<string>",
              "negative": true
            }
          ],
          "filters": "(category:Book OR category:Ebook) AND _tags:published",
          "optionalFilters": [
            "category:books<score=1>",
            "category:-movies<score=1>"
          ]
        }
      },
      "description": "Boost on-sale items",
      "enabled": true,
      "validity": [
        {
          "from": 123,
          "until": 123
        }
      ]
    }
  ],
  "nbHits": 20,
  "page": 0,
  "nbPages": 1
}
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"

model
enum<string>
required
Available options:
related-products,
bought-together,
trending-facets,
trending-items

Body

application/json

Recommend rules parameters.

query
string
default:""

Search query.

context
string

Only search for rules with matching context.

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

Whether to only show rules where the value of their enabled property matches this parameter. If absent, show all rules, regardless of their enabled property.

filters
string

Filter expression. This only searches for rules matching the filter expression.

Example:

"objectID:rr-123456"

facets
string[]

Include facets and facet values in the response. Use ['*'] to include all facets.

Facet name for rule objects or * as wildcard character.

Example:
["*"]
maxValuesPerFacet
integer

Maximum number of values to return for each facet.

Required range: 1 <= x <= 1000

Response

OK

hits
object[]
required

Recommend rules that match the search criteria.

nbHits
integer
required

Number of results (hits).

Example:

20

page
integer
default:0
required

Page of search results to retrieve.

Required range: x >= 0
nbPages
integer
required

Number of pages of results.

Example:

1

I