{"_id":"57fa66d914f95f0e0057984f","__v":0,"project":"5668fab608f90021008e882f","user":"5668fa9755e4b32100935d41","parentDoc":null,"version":{"_id":"5668fab608f90021008e8832","__v":19,"project":"5668fab608f90021008e882f","createdAt":"2015-12-10T04:08:22.769Z","releaseDate":"2015-12-10T04:08:22.769Z","categories":["5668fab708f90021008e8833","569740f124490c3700170a64","569742b58560a60d00e2c25d","569742bd0b09a41900b2446c","569742cd69393517000c82b3","569742f459a6692d003fad8f","569743020b09a41900b2446d","5697430b69393517000c82b5","56a17776470ae00d00c30642","56a2c48a831e2a0d0069b1ad","56b535757bccae0d00e9a1cd","56e1ff6aa49fdc0e005746b5","57e1c88115bf6522002a5e4e","57fa65275ba65a17008b988f","57fbeea34002550e004c032e","58474584889b6c2d00fb86e9","58475dcc64157f0f002f1907","587e7b5158666c2700965d4e","58a349fc30852819007ba083"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.18.0","version":"1.18"},"category":{"_id":"57fa65275ba65a17008b988f","__v":0,"version":"5668fab608f90021008e8832","project":"5668fab608f90021008e882f","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-10-09T15:41:27.321Z","from_sync":false,"order":7,"slug":"model-query-javascript","title":"Model query (Javascript)"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-10-09T15:48:41.854Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"Note that this documentation covers the case when you want to exclude items from recommendations on a *per-query* level. If there are some items you want to globally exclude from recommendations (i.e., you never want us to recommend them) you should set the `noShow` attribute for those items, as discussed in [Editing Fields/Hiding Item](doc:editing-fieldshiding-item).\n\nIf, on a given impression, you want to exclude specific items from the recommendations we return, you can specify the list of items in a field name called excludeItems in the opts of the register call, as shown below.\n\nNote that in most contexts, we already exclude most of the items the user has recently browsed, so you do not need to explicitly send the browsing history. This option is most useful when you are doing paginated recommendations, or if you have other areas not controlled by LiftIgniter and want to make sure that LiftIgniter's recommendations do not overlap with the recommendations in those areas.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"$p('register', {\\n                  max: 100, // Large number requested so you can see our full range of items\\n                  opts: {excludeItems : [\\\"url1\\\", \\\"url2\\\"]},\\n                  widget: 'default-widget', // name of widget\\n                  callback: function(resp) {\\n                    console.log(JSON.stringify(resp, null, 2));\\n                    console.log(\\\"// TEST.\\\");\\n                  }\\n               }\\n);\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/ad47600-li-excludeitems.gif\",\n        \"li-excludeitems.gif\",\n        1425,\n        734,\n        \"#d0cecc\"\n      ],\n      \"caption\": \"Illustration of how adding excludeItems changes the set of recommendations to ones that exclude the list sent.\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Alternative approaches\"\n}\n[/block]\nOther alternatives to this approach you can consider:\n\n* For global exclusion, consider [hiding the item using noShow](doc:editing-fieldshiding-item).\n* For excluding old items, [Set max age for recommended items](doc:set-max-age-for-recommended-items).\n* If you want to recommend from a small pool of items, consider using our option to [Rerank specified Items](doc:rerank-specified-items).\n* For restricting recommendations to within the same category, see [Recommend from category](doc:recommend-specific-category-of-items). To implement category-level or more complicated recommendation rules, please contact [Support](doc:support).\n* You can also do client-side filtering of the recommendations we return, prior to rendering.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Corresponding option for model query API endpoint\"\n}\n[/block]\nIf using the model query API endpoint, you can include an array of strings with the name `excludeItems` in the JSON body of the query. For more details, see the [model query API endpoint documentation](doc:model).","excerpt":"","slug":"exclude-items-from-recommendations","type":"basic","title":"Exclude items from recommendations"}

Exclude items from recommendations


Note that this documentation covers the case when you want to exclude items from recommendations on a *per-query* level. If there are some items you want to globally exclude from recommendations (i.e., you never want us to recommend them) you should set the `noShow` attribute for those items, as discussed in [Editing Fields/Hiding Item](doc:editing-fieldshiding-item). If, on a given impression, you want to exclude specific items from the recommendations we return, you can specify the list of items in a field name called excludeItems in the opts of the register call, as shown below. Note that in most contexts, we already exclude most of the items the user has recently browsed, so you do not need to explicitly send the browsing history. This option is most useful when you are doing paginated recommendations, or if you have other areas not controlled by LiftIgniter and want to make sure that LiftIgniter's recommendations do not overlap with the recommendations in those areas. [block:code] { "codes": [ { "code": "$p('register', {\n max: 100, // Large number requested so you can see our full range of items\n opts: {excludeItems : [\"url1\", \"url2\"]},\n widget: 'default-widget', // name of widget\n callback: function(resp) {\n console.log(JSON.stringify(resp, null, 2));\n console.log(\"// TEST.\");\n }\n }\n);", "language": "javascript" } ] } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/ad47600-li-excludeitems.gif", "li-excludeitems.gif", 1425, 734, "#d0cecc" ], "caption": "Illustration of how adding excludeItems changes the set of recommendations to ones that exclude the list sent." } ] } [/block] [block:api-header] { "type": "basic", "title": "Alternative approaches" } [/block] Other alternatives to this approach you can consider: * For global exclusion, consider [hiding the item using noShow](doc:editing-fieldshiding-item). * For excluding old items, [Set max age for recommended items](doc:set-max-age-for-recommended-items). * If you want to recommend from a small pool of items, consider using our option to [Rerank specified Items](doc:rerank-specified-items). * For restricting recommendations to within the same category, see [Recommend from category](doc:recommend-specific-category-of-items). To implement category-level or more complicated recommendation rules, please contact [Support](doc:support). * You can also do client-side filtering of the recommendations we return, prior to rendering. [block:api-header] { "type": "basic", "title": "Corresponding option for model query API endpoint" } [/block] If using the model query API endpoint, you can include an array of strings with the name `excludeItems` in the JSON body of the query. For more details, see the [model query API endpoint documentation](doc:model).