I'm trying to filter Nintendo's Algolia response so that I would only get games with dlcType that are NOT 'Individual', but for some reason its not working for me. However, if I facetFilter a field that contains an array (e.g. availability field) it works fine.
Here is my request:
{
"requests": [{
"indexName":"store_game_en_us",
"params":"query=overcooked&hitsPerPage=5&page=0&analytics=false&facetFilters=%22dlcType%3A-Individual%22"
}]
}
Here is the response/unfiltered i get:
{
"results": [
{
"hits": [
{
"availability": [
"Available now"
],
"classindDescriptors": null,
"classindRating": "L",
"corePlatforms": [
"Nintendo Switch"
],
"demoNsuid": null,
"editions": [
"Digital"
],
"esrbDescriptors": [
"Mild Cartoon Violence"
],
"esrbRating": "E",
"genres": [
"Simulation",
"Multiplayer",
"Strategy"
],
"nsoFeatures": [
"Online Play",
"Save Data Cloud"
],
"playModes": [
"TV mode",
"Tabletop mode",
"Handheld mode"
],
"playerCount": "4+",
"smecDescriptors": [
"Mild Cartoon Violence"
],
"smecRating": "A",
"softwareDeveloper": "Ghost Town Games and Team17",
"softwarePublisher": "Team17",
"createdAt": "2021-11-12T20:52:15.000Z",
"collectionPriceRange": "$10 - $19.99",
"description": "Enjoy hundreds of levels of cooperative cooking chaos across increasingly perilous and obscure kitchens. Overcooked! Goes Online For the first time ever, online multiplayer has been fully integrated into Overcooked! Revisit your favourite kitchens from t…",
"exclusive": false,
"featuredProduct": false,
"nsuid": "70010000029237",
"platinumPoints": null,
"platform": "Nintendo Switch",
"platformCode": "NINTENDO_SWITCH",
"price": {
"regPrice": 39.99,
"finalPrice": 19.99,
"salePrice": 19.99
},
"priceRange": "$10 - $19.99",
"productImage": "ncom/en_US/games/switch/o/overcooked-all-you-can-eat-switch/hero",
"franchises": [],
"title": "Overcooked! All You Can Eat",
"releaseDateDisplay": null,
"sku": "7100029237",
"updatedAt": "2022-05-03T19:19:56.000Z",
"url": "/store/products/overcooked-all-you-can-eat-switch/",
"urlKey": "overcooked-all-you-can-eat-switch",
"visibleInSearch": true,
"topLevelCategory": "Games",
"topLevelCategoryCode": "GAMES",
"topLevelFilters": [
"Deals"
],
"type": "game",
"dlcType": null,
"contentRatingCode": "E",
"hasDlc": false,
"objectID": "7100029237"
},
{
"availability": [
"Available now"
],
"classindDescriptors": null,
"classindRating": "L",
"corePlatforms": [
"Nintendo Switch"
],
"demoNsuid": null,
"editions": [
"Digital"
],
"esrbDescriptors": null,
"esrbRating": "E",
"genres": [
"Strategy",
"Party",
"Simulation"
],
"nsoFeatures": [
"Online Play",
"Save Data Cloud"
],
"playModes": [
"TV mode",
"Tabletop mode",
"Handheld mode"
],
"playerCount": "4+",
"smecDescriptors": null,
"smecRating": "A",
"softwareDeveloper": null,
"softwarePublisher": "Team17",
"createdAt": "2021-11-12T20:59:37.000Z",
"collectionPriceRange": "$20 - $39.99",
"description": "Out of the frying pan, into the fire... You’ve saved the world from the Ever Peckish. Now a new threat has arisen and it’s time to get back in the kitchen to stave off the hunger of The Unbread! ONLINE/LOCAL MULTIPLAYER MADNESS - You’ll knead to work tog…",
"exclusive": false,
"featuredProduct": false,
"nsuid": "70010000003402",
"platinumPoints": null,
"platform": "Nintendo Switch",
"platformCode": "NINTENDO_SWITCH",
"price": {
"regPrice": 24.99,
"finalPrice": 24.99,
"salePrice": null
},
"priceRange": "$20 - $39.99",
"productImage": "ncom/en_US/games/switch/o/overcooked-2-switch/hero",
"franchises": [],
"title": "Overcooked! 2",
"releaseDateDisplay": null,
"sku": "7100003402",
"updatedAt": "2022-05-06T16:57:52.000Z",
"url": "/store/products/overcooked-2-switch/",
"urlKey": "overcooked-2-switch",
"visibleInSearch": true,
"topLevelCategory": "Games",
"topLevelCategoryCode": "GAMES",
"topLevelFilters": [],
"type": "game",
"dlcType": null,
"contentRatingCode": "E",
"hasDlc": false,
"objectID": "7100003402"
},
{
"availability": [
"Available now"
],
"classindDescriptors": null,
"classindRating": "L",
"corePlatforms": [
"Nintendo Switch"
],
"demoNsuid": null,
"editions": [
"Digital"
],
"esrbDescriptors": [
"Mild Cartoon Violence"
],
"esrbRating": "E",
"genres": [
"Strategy",
"Party",
"Simulation"
],
"nsoFeatures": [
"Save Data Cloud"
],
"playModes": [
"TV mode",
"Tabletop mode",
"Handheld mode"
],
"playerCount": "4+",
"smecDescriptors": [
"Mild Cartoon Violence"
],
"smecRating": "A",
"softwareDeveloper": null,
"softwarePublisher": "Team17",
"createdAt": "2021-11-12T20:52:10.000Z",
"collectionPriceRange": "$10 - $19.99",
"description": "Working as a team, you and your fellow chefs must prepare, cook and serve up a variety of tasty orders before the baying customers storm out in a huff. Sharpen your knives and dust off your chef’s whites, there isn’t mushroom for error and the steaks are…",
"exclusive": false,
"featuredProduct": false,
"nsuid": "70010000000883",
"platinumPoints": null,
"platform": "Nintendo Switch",
"platformCode": "NINTENDO_SWITCH",
"price": {
"regPrice": 19.99,
"finalPrice": 19.99,
"salePrice": null
},
"priceRange": "$10 - $19.99",
"productImage": "ncom/en_US/games/switch/o/overcooked-special-edition-switch/hero",
"franchises": [],
"title": "Overcooked Special Edition",
"releaseDateDisplay": null,
"sku": "7100000883",
"updatedAt": "2022-05-03T21:23:00.000Z",
"url": "/store/products/overcooked-special-edition-switch/",
"urlKey": "overcooked-special-edition-switch",
"visibleInSearch": true,
"topLevelCategory": "Games",
"topLevelCategoryCode": "GAMES",
"topLevelFilters": [],
"type": "game",
"dlcType": null,
"contentRatingCode": "E",
"hasDlc": false,
"objectID": "7100000883"
},
{
"availability": [
"Available now"
],
"classindDescriptors": null,
"classindRating": "L",
"corePlatforms": [
"Nintendo Switch"
],
"demoNsuid": null,
"editions": [
"Digital"
],
"esrbDescriptors": null,
"esrbRating": "E",
"genres": null,
"nsoFeatures": null,
"playModes": [
"TV mode",
"Tabletop mode",
"Handheld mode"
],
"playerCount": null,
"smecDescriptors": null,
"smecRating": "A",
"softwareDeveloper": null,
"softwarePublisher": "Team17",
"createdAt": "2021-11-12T23:40:55.000Z",
"collectionPriceRange": "$10 - $19.99",
"description": "Cook alone or with friends as you travel through the onion kingdom and master over 20 recipes across 130 sizzling levels. Overcooked! 2: Gourmet Edition The Overcooked! 2 Gourmet Edition gives players every course of award-winning chaotic cooking fun wi…",
"exclusive": false,
"featuredProduct": false,
"nsuid": "70070000010201",
"platinumPoints": null,
"platform": "Nintendo Switch",
"platformCode": "NINTENDO_SWITCH",
"price": {
"regPrice": 48.49,
"finalPrice": 12.12,
"salePrice": 12.12
},
"priceRange": "$10 - $19.99",
"productImage": "ncom/en_US/dlc/switch-dlc/overcooked-2-dlc/rom-bundle/overcooked-2-gourmet-edition/image",
"franchises": [],
"title": "Overcooked! 2 - Gourmet Edition",
"releaseDateDisplay": null,
"sku": "7700010201",
"updatedAt": "2022-05-06T17:49:37.000Z",
"url": "/store/products/overcooked-2-gourmet-edition-switch/",
"urlKey": "overcooked-2-gourmet-edition-switch",
"visibleInSearch": true,
"topLevelCategory": "Games",
"topLevelCategoryCode": "GAMES",
"topLevelFilters": [
"Deals",
"Games with DLC"
],
"type": "game",
"dlcType": "ROM Bundle",
"contentRatingCode": "E",
"hasDlc": true,
"objectID": "7700010201"
},
{
"availability": [
"Available now"
],
"classindDescriptors": null,
"classindRating": "L",
"corePlatforms": [
"Nintendo Switch"
],
"demoNsuid": null,
"editions": [
"Digital"
],
"esrbDescriptors": null,
"esrbRating": "E",
"genres": null,
"nsoFeatures": null,
"playModes": [
"Handheld mode",
"Tabletop mode",
"TV mode"
],
"playerCount": null,
"smecDescriptors": null,
"smecRating": "A",
"softwareDeveloper": null,
"softwarePublisher": "Team17",
"createdAt": "2021-11-12T22:17:33.000Z",
"collectionPriceRange": "$0 - $9.99",
"description": "Overcooked! 2 Carnival of Chaos invites players to a celebration of all things cooking, co-op and chaos! This colourful new DLC will put players to the test as you take on combo meals and that kitchen essential, the canon! Canons! An unconventional kitc…",
"exclusive": false,
"featuredProduct": false,
"nsuid": "70050000011524",
"platinumPoints": null,
"platform": "Nintendo Switch",
"platformCode": "NINTENDO_SWITCH",
"price": {
"regPrice": 5.99,
"finalPrice": 5.99,
"salePrice": null
},
"priceRange": "$5 - $9.99",
"productImage": "ncom/en_US/dlc/switch-dlc/overcooked-2-dlc/individual/overcooked-2-carnival-of-chaos/image",
"franchises": [],
"title": "Overcooked! 2 - Carnival of Chaos",
"releaseDateDisplay": null,
"sku": "7500011524",
"updatedAt": "2022-05-06T22:25:01.000Z",
"url": "/store/products/overcooked-2-carnival-of-chaos-70050000011524-switch/",
"urlKey": "overcooked-2-carnival-of-chaos-70050000011524-switch",
"visibleInSearch": true,
"topLevelCategory": "Games",
"topLevelCategoryCode": "GAMES",
"topLevelFilters": [
"DLC"
],
"type": "game",
"dlcType": "Individual",
"contentRatingCode": "E",
"hasDlc": true,
"objectID": "7500011524"
}
],
"nbHits": 11,
"page": 0,
"nbPages": 3,
"hitsPerPage": 5,
"exhaustiveNbHits": true,
"exhaustiveTypo": true,
"query": "overcooked",
"params": "query=overcooked&hitsPerPage=5&page=0&analytics=false&facetFilters=",
"index": "store_game_en_us",
"renderingContent": {},
"processingTimeMS": 1
}
]
}
First of all make sure the attribute is added as an attribute for faceting .You can either use the API or the Algolia dashboard for that refer
According to the docs facetFilters
needs to be an array. From what I see you have set it to a string like facetFilters:"dlcType:-Bundle"
. Instead you need facetFilters:["dlcType:-Bundle"]
therefore the params
will become "query=overcooked&hitsPerPage=5&page=0&analytics=false&facetFilters=%5B%22dlcType%253A-Bundle%22%5D"
Also writing the params
as a string by hand will be cumbersome even with encodeURI
. Instead you can define the params
as a Javascript object. An example structure of the requests array is below for a demo playground. You can learn the rules for writing the facetFilters
array here
{
"requests": [
{
"indexName": "bestbuy",
"params": {
"query": "app",
"hitsPerPage": 7,
"maxValuesPerFacet": 3,
"page": 0,
"facets": [
"category"
],
"tagFilters": "",
"facetFilters": [
[
"category:Cell Phone Cases & Clips",
"category:Cases, Armbands & Watchbands"
]
]
}
},
{
"indexName": "bestbuy",
"params": {
"query": "app",
"hitsPerPage": 1,
"maxValuesPerFacet": 3,
"page": 0,
"attributesToRetrieve": [],
"attributesToHighlight": [],
"attributesToSnippet": [],
"tagFilters": "",
"analytics": false,
"clickAnalytics": false,
"facets": "category"
}
}
]
}
Play around with it and look at the network request to get an idea about the requests
array structure.