Strict combined facets

Hello,

I don’t know if my topic title is correct since I really don’t know how to call such behaviour.

So I will provide an example and explain my need
Here’s a sample of my data :

[
   {
      "title":"Video 1",
      "links":[
         {
            "platform":"youtube",
            "countries":[
               "France",
               "Spain"
            ]
         },
         {
            "platform":"vimeo",
            "countries":[
               "Italy",
               "Germany"
            ]
         }
      ],
      "objectID":"1"
   },
   {
      "title":"Video 2",
      "links":[
         {
            "platform":"youtube",
            "countries":[
               "Italy"
            ]
         },
         {
            "platform":"vimeo",
            "countries":[
               "Germany"
            ]
         }
      ],
      "objectID":"2"
   }
]

I have two facets, “Platforms” which allows to filter through video available on specific platforms (youtube, vimeo…) and “Countries” which allows to filter on countries where the video is available.

As you see in the above sample, each video can have multiple links with different countries. And my issue is that I would like to make a facet to match on specific links.

For example, if I pick “Youtube” as a platform, and “Italy” as a country, I would like to only get results for Youtube video available in Italy. But with facets’ default behaviour it will return any video that has one youtube link and is available in Italy through any of its links.

  • Youtube + Italy => should return Video 2
  • Vimeo + Germany => should return Video 1 & 2
  • Youtube + Germany => should return nothing

Is there any solution to create that kind of behaviour where filters should be “combined” on the object’s data? Whether it is custom, vue-instantsearch or through Algolia dashboard.

Thanks for your help

I can’t think of a good way to filter on the values within these complex objects they way you want (“Only if countries:Germany within the object where platform:Vimeo”).

You’ll need to flatten these attributes to use this as facet filters. If there’s a fixed number of platforms, one way to do this would be to have a country attribute per platform:

[
   {
      "title":"Video 1",
      "links":[
          "youtube.countries":[
               "France",
               "Spain"
           ],
          "vimeo.countries":[
               "Italy",
               "Germany"
           ],
      ],
      "objectID":"1"
   },