search
Examples
public class Product
{
public string ObjectID { get; set; }
public string Name { get; set; }
public string Category { get; set; }
public float Price { get; set; }
}
public class RecommendedProduct : Product, Algolia.Search.Models.Recommend.IRecommendHit
{
public float Score { get; set; }
}
var requests = new List<Algolia.Search.Models.Recommend.RecommendRequest> {
new Algolia.Search.Models.Recommend.RecommendRequest {
IndexName = "your_index_name",
ObjectID = "your_object_id",
Model = "bought-together",
}
}
var recommendations = recommendClient.GetRecommendations<RecommendedProduct>(requests);
// Asynchronous
var recommendations =
await recommendClient.GetRecommendationsAsync<RecommendedProduct>(requests);
Parameters
Show child attributes
Show child attributes
Facet attribute for which to get recommendations.
Name of the index.
Name of the recommendation model to use.
One of:
bought-together, related-products, trending-items, trending-facets.Object ID for which to get recommendations.
Threshold for the recommendations confidence score (between 0 and 100).
Only recommendations with a greater score are returned.
Facet value for which to get recommendations for. This parameter must be used along with #.
Search parameters to use as fallback when there are no recommendations.
Maximum number of recommendations to retrieve.
Depending on the available recommendations and the other request parameters,
the actual number of recommendations may be lower.
If you don’t set
maxRecommendations or set it to 0,
all matching recommendations are returned, and no fallback request is performed.Search parameters for filtering the recommendations.
Response
List of results in the order they were submitted, one per query.Example:
JSON
{
"results": [
{
"hits": [
{
// ...,
"_score": 32.72
}
],
},
]
}
Show child attributes
Show child attributes
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 thegetLogs method.
Don’t rely on the order of properties—JSON objects don’t preserve key order.
JSON
{
"results": [
{
"hits": [
{
"_highlightResult": {
"category": {
"matchLevel": "none",
"matchedWords": [],
"value": "Men - T-Shirts"
},
"image_link": {
"matchLevel": "none",
"matchedWords": [],
"value": "https://example.org/image/D05927-8161-111-F01.jpg"
},
"name": {
"matchLevel": "none",
"matchedWords": [],
"value": "Jirgi Half-Zip T-Shirt"
}
},
"_score": 32.72,
"category": "Men - T-Shirts",
"image_link": "https://example.org/image/D05927-8161-111-F01.jpg",
"name": "Jirgi Half-Zip T-Shirt",
"objectID": "D05927-8161-111",
"position": 105,
"url": "men/t-shirts/d05927-8161-111"
}
],
"processingTimeMS": 1,
}
]
}