--- title: Query a Product Recommendation model slug: n4b80123 canonical_url: https://docs.coveo.com/en/n4b80123/ collection: javascript-search-framework source_format: adoc --- # Query a Product Recommendation model This article describes how to query a [Product Recommendation (PR)](https://docs.coveo.com/en/3132/) [model](https://docs.coveo.com/en/1012/) with the [Coveo JavaScript Search Framework](https://docs.coveo.com/en/187/). If you wish to query a PR model with the [Coveo Headless library](https://docs.coveo.com/en/lcdf0493/), see [Query a Product Recommendation model with Headless](https://docs.coveo.com/en/o4ue0204/). > **Note** > > In order to render recommendations with JSUI, you must have first completed the prerequisite steps described in [Leverage Coveo Machine Learning Product Recommendations (PR)](https://docs.coveo.com/en/3382/). ## Render recommendations in a JSUI search interface Coveo ML PR offers different strategies to adapt its recommendations according to the current user context. To leverage one of those strategies in your commerce solution, write code that: * Calls the Coveo Search API to query the desired ML PR model. * Renders the recommendations returned by the Coveo Search API. . Use the JavaScript Search Framework to request and render recommendations. **Example** Here's an example of a product page that renders a list of recommendations: ```html
``` . Depending on the strategy used by the targeted ML PR model, the query may have to include additional [ML query parameters](https://docs.coveo.com/en/13#operation/searchUsingPost-mlParameters). To learn which parameters must be included, click the chosen strategy: ** [User recommender](#user-recommender-user) ** [Frequently bought together](#frequently-bought-together-frequentbought) ** [Frequently viewed together](#frequently-viewed-together-frequentviewed) ** [Cart recommender](#cart-recommender-cart) ** [Popular items: viewed](#popular-items-viewed-popularviewed) ** [Popular items: bought](#popular-items-bought-popularbought) ### User recommender (`user`) No additional ML query parameters must be configured for the model to provide its recommendations. ### Frequently bought together (`frequentBought`) When leveraging the **Frequently bought together** strategy, pass a [seed product](https://docs.coveo.com/en/n5jg0219/) in the `itemId` ML query parameter for the model to provide its recommendations. **Example** ```json {"mlParameters": {"itemId": ""}} ``` ### Frequently viewed together (`frequentViewed`) When leveraging the **Frequently viewed together** strategy, pass a [seed product](https://docs.coveo.com/en/n5jg0219/) in the `itemId` ML query parameter for the model to provide its recommendations. **Example** ```json {"mlParameters": {"itemId": ""}} ``` If the model is queried from a commerce interface where multiple items are shown, multiple seed products can be provided by using the `itemIds` ML query parameter instead. ```json {"mlParameters": {"itemIds": ["", "", ""]}} ``` ### Cart recommender (`cart`) When leveraging the **Cart recommender** strategy, pass a [seed product](https://docs.coveo.com/en/n5jg0219/) in the `itemIds` ML query parameter for the model to provide its recommendations. **Example** ```json {"mlParameters": {"itemIds": ["", "", ""]}} ``` You can specify as many `SEED_PRODUCT_ID` values as you want. ### Popular items: viewed (`popularViewed`) No additional ML query parameters must be configured for the model to provide its recommendations. However, you may want to filter the provided recommendations by specific category or brand. You can achieve this by passing the input product category and brand respectively in the [`categoryFilter`](#categoryfilter) and [`brandfilter`](#brandfilter) ML query parameters. > **Note** > > Currently, analytics data is used by the model to retrieve the product's category and brand. > In the future, this information will be retrieved directly from the [catalog entity](https://docs.coveo.com/en/3143/). #### `categoryFilter` Passing the input product category in the `categoryFilter` ML query parameter: ```json {"mlParameters": {"categoryFilter": ""}} ``` > **Important** > > Ensure that your commerce interface sends the product [`category`](https://docs.coveo.com/en/l29e0540#category-string) to [Coveo Analytics](https://docs.coveo.com/en/182/). #### `brandFilter` Passing the input product brand in the `brandFilter` ML query parameter: ```json {"mlParameters": {"brandFilter": ""}} ``` > **Important** > > Make sure that your commerce interface sends the product [`brand`](https://docs.coveo.com/en/l29e0540#brand-string) to Coveo UA. ### Popular items: bought (`popularBought`) No additional ML query parameters must be configured for the model to provide its recommendations. However, you may want to filter the provided recommendations by specific category or brand. You can achieve this by passing the input product category and brand respectively in the [`categoryFilter`](#categoryBought) and [`brandfilter`](#brandBought) ML query parameters. > **Note** > > Currently, analytics data is used by the model to retrieve the product's category and brand. > In the future, this information will be retrieved directly from the [catalog entity](https://docs.coveo.com/en/3143/). [#categoryBought] #### `categoryFilter` Passing the input product category in the `categoryFilter` ML query parameter: ```json {"mlParameters": {"categoryFilter": ""}} ``` > **Important** > > Make sure that your commerce interface sends the product [`category`](https://docs.coveo.com/en/l29e0540#category-string) to Coveo UA. [#brandBought] #### `brandFilter` Passing the input product brand in the `brandFilter` ML query parameter: ```json {"mlParameters": {"brandFilter": ""}} ``` > **Important** > > Make sure that your commerce interface sends the product [`brand`](https://docs.coveo.com/en/l29e0540#brand-string) to Coveo UA.