Recommendation sample: broadening concepts
The broadenBy parameter increases the number of recommendations that are returned by considering concepts on a higher level in the concept hierarchy.
search(
recommend: {
id: "tcm:5-449"
concepts: [
{
connectorId:"ingredients"
broadenBy: 1
}
]
}
)
The above sample, like an earlier sample, disregards the glassware concept again by omitting it from the concepts array. As for the ingredients concept, it has a broadenBy parameter. To understand what this means, consider the following example.
Imagine that the beverage identified by the ID has concepts under ingredients called coffee and milk. (Let's say it's a cappuccino.) Without the broadenBy parameter set to 1, the parameter would default to its normal value, 0, and only other beverages containing coffee, milk or both would be returned as recommendations. For example, a latte or a macchiato.
broadenBy set to 1, the parent concepts of coffee and milk would also be considered:
milkgets expanded with its parent conceptdairy productscoffeegets expanded with its parent conceptnon-alcoholic
Thus, by setting broadenBy to 1, you now make the query suggest not just drinks with milk or coffee or both, but also drinks with any dairy products, and any non-alcoholic drinks. However, when ranked, the recommendations with the explicitly specified concepts, milk or coffee or both (recommendations like latte and macchiato) rank higher than recommendations with only the implicit, derived concepts, dairy products or non-alcoholic drinks (recommendations like yogurt, which is a non-alcoholic dairy product, but contains neither milk nor coffee).