Recommendations APIManaged Fusion 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.
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.
For more information, view the API specification.
Recommendation types
The API includes separate endpoints for retrieving different types of recommendations:
|
Get items for a defined query. The response is a list of document IDs and their weights. |
|
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:
|
The query parameters (in a section named |
|
Depending on the recommendation type:
|
Examples
Below are examples for each recommendation type.
itemsForQuery
Get the top items for the query 'ipod':
curl -u USERNAME:PASSWORD https://EXAMPLE_COMPANY.b.lucidworks.cloud/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
curl -u USERNAME:PASSWORD https://EXAMPLE_COMPANY.b.lucidworks.cloud/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
} ]
}