Product Selector

Fusion 5.9
    Fusion 5.9

    Recommendations APIFusion Job REST Server APIs

    The Recommendations REST API uses signals and aggregated signals to return a list of items that can be used for recommendations.

    For more information, view the API specification.

    To use the REST API Recommendations service to get recommendations for items in some collection, that collection must have associated signals and aggregated-signals system collections. How good the recommendations are depends on how well the information in the signals and aggregated signals collections, which is derived from observed user behavior, matches user behavior going forward.

    In addition to these endpoints, is also possible to get recommendations as part of a query request.

    See Recommendations and Boosting for a discussion of when to use the API and when to use recommender query stages.

    Recommendation types

    The API includes separate endpoints for retrieving different types of recommendations:

    itemsForQuery

    Get items for a defined query.

    The response is a list of document IDs and their weights.

    queriesForItem

    Get queries for a defined item (a document ID). This finds the top queries that led users to the defined item.

    The response is a list of query terms and their weights.

    Output

    The output includes the following sections:

    header

    The query parameters (in a section named queryParams) and the total time it took to process the query.

    items

    Depending on the recommendation type:

    • itemsForQuery

      The document IDs and the weights of aggregated events that match the query. This type supports a debug option that adds a debug section to the output.

    • queriesForItem

      The queries and the weights of aggregated events that match the document ID.

    Examples

    Below are examples for each recommendation type.

    itemsForQuery

    Get the top items for the query 'ipod':

    INPUT
    curl -u USERNAME:PASSWORD https://FUSION_HOST:FUSION_PORT/api/recommend/lucidworks102/itemsForQuery?q=ipod&fq=count_d:4&debug=true

    OUTPUT

    {
      "header" : {
        "queryParams" : {
          "aggrType" : "*",
          "rows" : 10,
          "collection" : "lucidworks102",
          "aggrRows" : 100,
          "debug" : true,
          "q" : "ipod",
          "fq" : [ "count_d:4" ]
        },
        "totalTime" : 5
      },
      "items" : [ {
        "weight" : 1.0726584E-11,
        "docId" : "8771929"
      }, {
        "weight" : 3.865899E-12,
        "docId" : "9225439"
      }, {
        "weight" : 9.230597E-12,
        "docId" : "3109302"
      } ],
      "debugInfo" : {
        "aggrTime" : 1,
        "queryTime" : 4,
        "solrParams" : {
          "mm" : [ "50%" ],
          "pf" : [ "query_t^3", "query_t~2^7", "query_t~0^1" ],
          "fl" : [ "id", "doc_id_s", "weight_d" ],
          "sort" : [ "score desc,weight_d desc" ],
          "q" : [ "ipod" ],
          "qf" : [ "query_t" ],
          "collection" : [ "lucidworks102_signals_aggr" ],
          "fq" : [ "aggr_type_s:*", "count_d:4" ],
          "rows" : [ "100" ],
          "defType" : [ "edismax" ]
        }
      }
    }

    queriesForItem

    INPUT
    curl -u USERNAME:PASSWORD https://FUSION_HOST:FUSION_PORT/api/recommend/lucidworks102/queriesForItem?docId=9225439

    OUTPUT

    {
      "header" : {
        "queryParams" : {
          "aggrType" : "*",
          "rows" : 10,
          "collection" : "lucidworks102",
          "docId" : "9225439"
        },
        "totalTime" : 8
      },
      "items" : [ {
        "query" : "ipod",
        "weight" : 3.865899E-12
      }, {
        "query" : "columbusday ipod mp3 20111009",
        "weight" : 3.5141304E-12
      }, {
        "query" : "apple itouch",
        "weight" : 2.3619889E-12
      }, {
        "query" : "ipod 4th generation",
        "weight" : 1.6436526E-12
      }, {
        "query" : "ipod touch 4th generation",
        "weight" : 9.674966E-13
      }, {
        "query" : "onlinemidnightsale ipod mp3players",
        "weight" : 9.568035E-13
      }, {
        "query" : "ipod touch",
        "weight" : 7.774231E-13
      }, {
        "query" : "itouch",
        "weight" : 7.707221E-13
      } ]
    }