Get recommendations

This is for:

In this article

The REST Search API allows you to get Coveo Machine Learning (Coveo ML) content recommendations based on the user action history such as their recently viewed pages.

The pipeline uses these recommendations to change the advancedExpression and rankingExpression before sending the request to the index.

  • Coveo ML response example:

                "contentType": "Documentation",
                "contentIdKey": "sfid",
                "contentIdValue": "kA130000000Pv61CAC",
                "title":"Configuring the server"
  • REST API call to get content recommendations:[{"name":"PageView", "value":"", "time":"2016-06-03T00:00:00.0000Z"}]

    Ranking expression in the response block:

    "rankingExpressions" : [ {
        "expression" : "@urihash=\"vlTp6wQP Z 6wSKF\"",
        "modifier" : 250,
        "isConstant" : false
      }, {
        "expression" : "@urihash=\"VrulQxaNUFgGzENC\"",
        "modifier" : 107,
        "isConstant" : false
      }, {
        "expression" : "@urihash=\"cBQGBj1wEoVt9ETR\"",
        "modifier" : 102,
        "isConstant" : false
      }, {
        "expression" : "@urihash=\"5Ht1bPr4tbQd Ns \"",
        "modifier" : 95,
        "isConstant" : false
      }, {
        "expression" : "@urihash=\"wKxci395EKjpbIDl\"",
        "modifier" : 93,
        "isConstant" : false
      } ],

    Advanced expression in the response block:

    "advancedExpression" : "@urihash=\"vlTp6wQP Z 6wSKF\" OR @urihash=\"VrulQxaNUFgGzENC\" OR @urihash=\"cBQGBj1wEoVt9ETR\" OR @urihash=\"5Ht1bPr4tbQd Ns \" OR @urihash=\"wKxci395EKjpbIDl\"",


Since this feature is part of a search at REST API, you can call it using all the other parameters. Only make sure to add the new parameter actionsHistory.


The history of the 10 last actions taken by the current user.

When using the Coveo JavaScript Search Framework that information will be stored in a cookie and sent to the server when the recommendation feature is activated.

Each action history must contain a name, value and time.

  "name":"PageView", "value":"",


The format of the results. Use xlsx for excel and json for JSON. By default, the service returns the results in a JSON format.