POST /1/indexes/{indexName}/{model}/recommend/rules/batch

Create or update a batch of Recommend Rules

Each Recommend Rule is created or updated, depending on whether a Recommend Rule with the same objectID already exists. You may also specify true for clearExistingRules, in which case the batch will atomically replace all the existing Recommend Rules.

Recommend Rules are similar to Search Rules, except that the conditions and consequences apply to a source item instead of a query. The main differences are the following:

Servers

Path parameters

Name Type Required Description
indexName String Yes

Name of the index on which to perform the operation.

model String Yes

Recommend model.

Possible values:

  • "related-products"
  • "trending-items"
  • "trending-facets"
  • "bought-together"

Request headers

Name Type Required Description
Content-Type String Yes The media type of the request body.

Default value: "application/json"

Request body fields

Name Type Required Description
[] Array Yes
[]._metadata Object No

Rule metadata.

[]._metadata.lastUpdate String No

Date and time when the object was updated, in RFC 3339 format.

[].description String No

Description of the rule's purpose. This can be helpful for display in the Algolia dashboard.

[].condition Object No

Condition that triggers the rule. If not specified, the rule is triggered for all recommendations.

[].condition.filters String No

Filter expression to only include items that match the filter criteria in the response.

You can use these filter expressions:

  • Numeric filters. <facet> <op> <number>, where <op> is one of <, <=, =, !=, >, >=.
  • Ranges. <facet>:<lower> TO <upper> where <lower> and <upper> are the lower and upper limits of the range (inclusive).
  • Facet filters. <facet>:<value> where <facet> is a facet attribute (case-sensitive) and <value> a facet value.
  • Tag filters. _tags:<value> or just <value> (case-sensitive).
  • Boolean filters. <facet>: true | false.

You can combine filters with AND, OR, and NOT operators with the following restrictions:

  • You can only combine filters of the same type with OR. Not supported: facet:value OR num > 3.
  • You can't use NOT with combinations of filters. Not supported: NOT(facet:value OR facet:value)
  • You can't combine conjunctions (AND) with OR. Not supported: facet:value OR (facet:value AND facet:value)

Use quotes around your filters, if the facet attribute name or facet value has spaces, keywords (OR, AND, NOT), or quotes. If a facet attribute is an array, the filter matches if it matches at least one element of the array.

For more information, see Filters.

[].condition.context String No

An additional restriction that only triggers the rule, when the search has the same value as ruleContexts parameter. For example, if context: mobile, the rule is only triggered when the search request has a matching ruleContexts: mobile. A rule context must only contain alphanumeric characters.

[].consequence Object No

Effect of the rule.

[].consequence.params Object No

Filter or boost recommendations matching a facet filter.

[].consequence.params.filters String No

Filter expression to only include items that match the filter criteria in the response.

You can use these filter expressions:

  • Numeric filters. <facet> <op> <number>, where <op> is one of <, <=, =, !=, >, >=.
  • Ranges. <facet>:<lower> TO <upper> where <lower> and <upper> are the lower and upper limits of the range (inclusive).
  • Facet filters. <facet>:<value> where <facet> is a facet attribute (case-sensitive) and <value> a facet value.
  • Tag filters. _tags:<value> or just <value> (case-sensitive).
  • Boolean filters. <facet>: true | false.

You can combine filters with AND, OR, and NOT operators with the following restrictions:

  • You can only combine filters of the same type with OR. Not supported: facet:value OR num > 3.
  • You can't use NOT with combinations of filters. Not supported: NOT(facet:value OR facet:value)
  • You can't combine conjunctions (AND) with OR. Not supported: facet:value OR (facet:value AND facet:value)

Use quotes around your filters, if the facet attribute name or facet value has spaces, keywords (OR, AND, NOT), or quotes. If a facet attribute is an array, the filter matches if it matches at least one element of the array.

For more information, see Filters.

[].consequence.params.optionalFilters[] Array No

Filters to promote or demote records in the search results.

Optional filters work like facet filters, but they don't exclude records from the search results. Records that match the optional filter rank before records that don't match. Matches with higher weights (<score=N>) rank before matches with lower weights. If you're using a negative filter facet:-value, matching records rank after records that don't match.

[].consequence.params.automaticFacetFilters[] Array No

Filter recommendations that match or don't match the same facet:facet_value combination as the viewed item.

[].consequence.params.automaticFacetFilters[].facet String No

Facet attribute.

[].consequence.params.automaticFacetFilters[].negative Boolean No

Whether the filter is negative. If true, recommendations must not have the same value for the facet attribute. If false, recommendations must have the same value for the facet attribute.

[].consequence.promote[] Array No

Place items at specific positions in the list of recommendations.

[].consequence.promote[].objectID String No

Unique record identifier.

[].consequence.promote[].position Integer No

Index in the list of recommendations where to place this item.

[].consequence.hide[] Array No

Exclude items from recommendations.

[].consequence.hide[].objectID String No

Unique record identifier.

[].enabled Boolean No

Indicates whether to enable the rule. If it isn't enabled, it isn't applied at query time.

Default value: true

[].objectID String No

Unique identifier of a rule object.

[].validity[] Array No

Time periods when the rule is active.

[].validity[].until Integer Yes

When the rule should stop to be active, in Unix epoch time.

[].validity[].from Integer Yes

When the rule should start to be active, in Unix epoch time.

How to start integrating

  1. Add HTTP Task to your workflow definition.
  2. Search for the API you want to integrate with and click on the name.
    • This loads the API reference documentation and prepares the Http request settings.
  3. Click Test request to test run your request to the API and see the API's response.