recommendClient.execute { val query = RelatedProductsQuery( indexName = "yourIndexName", objectID = "yourObjectID" ) get relatedProducts List(query) }
let options = RelatedProductsOptions(indexName: "IndexName", objectID: "B018APC4LE")recommendClient.getRelatedProducts(options: [options]) { result in if case .success(let response) = result { print("Response: \(response)") }}
Parameters
object[]
required
Show child attributes
string
required
The name of the target index.
string
required
The objectID of the item to get recommendations for.
number
required
Threshold for the recommendations confidence score (between 0 and 100).
Only recommendations with a greater score are returned.
object
List of search parameters to send,
except page, hitsPerPage, offset, length.Additional filters to use as fallback when there aren’t enough recommendations.
integer
The number of recommendations to retrieve.
Depending on the available recommendations and the other request parameters, the actual number of hits may be lower than that.
If maxRecommendations isn’t provided or set to 0, all matching recommendations are returned, and no fallback request is performed.
object
List of search parameters to send.
except page, hitsPerPage, offset, length.
Response
object[]
List of results in the order they were submitted, one per query.Example:
The confidence score of the recommended item, the closer it is to 100, the more relevant.
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.