Facet filtering on nested elements

Hello,

I can’t seem to wrap my head around a specific filter I’m trying to build. Here’s my index structure for one record:

name: Testing webhook
status: Finalized
tags: []
elements: [
{ element_id: 36, element_type_name: 'yes or no', content: true},
{ element_id: 35, element_type_name: yes or no', content: false}
] 

I’m trying to get all records that have element_id:36 set to element.content: true.

Here’s a query I’m building :

index.search("", {
 "hitsPerPage": "10",
 "page": "0",
 "analytics": "false",
 "attributesToRetrieve": "*",
 "facets": "[\"elements.element_id\",\"elements.content\",\"platform_id\",\"season\",\"status\"]",
 "facetFilters": "[[\"elements.content:true\"],[\"elements.element_id:36\"]]"
});

But looks like this is giving me everything that has either element_id: 36 or element.content: true
Am I doing something wrong with the structure of my index?

Thanks

If you haven’t already, try a single pair of brackets?

facetFilters: ["elements.content:true", "elements.element_id:36"]

Relevant docs here

Well technically I’m trying to get the result from the InstantSearch widget, and I don’t see how to add facetFilters in it in the documentation.

The closest I come to would be https://community.algolia.com/instantsearch.js/v1/documentation/#refinementlist but that doesn’t seem to handle different elements

Ah, got it. There’s a searchParameters object you can use when initializing instantsearch.

Example taken from here

const search = instantsearch({
  appId: 'latency',
  apiKey: '6be0576ff61c053d5f9a3225e2a90f76',
  indexName: 'instant_search',
  searchParameters: {
    hitsPerPage: 8,
    // Include facetFilters code here
  },
});

Docs:
Initialization
Search Parameters

Hope that helps!