Fetch records where both facet conditions are satisfied

Hello,

An example data structure of my record(s) are:

{
    foo: "bar",
    foo1: [
        { b1: "x", b2: "y" }
    ]
}

I am using React InstantSearch widgets where I have many refinement lists, two of which are on foo1.b1 and foo.b2 attributes.

Expectation - user selects value “x” for foo1.b1 attribute and “y” for foo1.b2 attribute. Records that have both values set should be returned. (AND condition).

Actual: Records where either foo1.b1 is “x” OR foo1.b2 is “y” are being returned.

As I understand the facet filter should be set as:

facetFilters: ['foo1.b1:x', 'foo1.b2:y']

but instead they are being set as

facetFilters: ['foo1.b1:x', ['foo1.b2:y']]

Since I am using React InstantSearch widget and RefinementList, I am not sure how I can achieve the above. I looked at connectRefinmentList and virtual refinement lists but they seem to only work with a single attribute at a time.

Hi @callmekatootie

I was just playing with this in my account. I set up records like this:

{
  "name": "Bah",
  "foo1": [
    {
      "b1": "x",
      "b2": "y"
    }
  ],
  "objectID": "3"
}

I added “foo1.b1” and “foo1.b2” as facet attributes, and I selected values for both in my UI and confirmed it was displaying only the results that matched both values:
Demo UI

Any chance you have a codesandbox or similar that reproduces what you’re seeing?

Thank you for your demo link. TIL that we can generate demos from the algolia dashboard.

Here’s mine - Demo link

Select Language as English and Language Level as Conversational.

Expected: Only Item # 3 and Item # 4 to show up.

Actual: All 4 items are seen.

Hey @chuck.meyer - did you get a chance to check this out? Any hints for me that I can look into further

Hey @callmekatootie – sorry, I was on vacation last week. I’ve got this up in a tab now to take a look at it today.

1 Like

Sounds good. Thanks for the update.

Hey @callmekatootie , can you share the JSON for these four records from this example as well?

Here you go:

[
  {
    "foo1": [
      {
        "x": "Conversational",
        "y": "Portuguese"
      },
      {
        "x": "Fluent",
        "y": "English"
      }
    ],
    "id": 2,
    "name": "Item 2",
    "title": "Item 2",
    "objectID": "847af79182a5c_dashboard_generated_id"
  },
  {
    "foo1": [
      {
        "x": "Conversational",
        "y": "Spanish"
      },
      {
        "x": "Native",
        "y": "English"
      }
    ],
    "id": 1,
    "name": "Item 1",
    "title": "Item 1",
    "objectID": "3f851c57e3a01_dashboard_generated_id"
  },
  {
    "foo1": [
      {
        "x": "Conversational",
        "y": "English"
      }
    ],
    "id": 3,
    "name": "Item 3",
    "title": "Item 3",
    "objectID": "19d3c116a06312_dashboard_generated_id"
  },
  {
    "foo1": [
      {
        "x": "Conversational",
        "y": "English"
      }
    ],
    "id": 4,
    "name": "Item 4",
    "title": "Item 4",
    "objectID": "129bea705affcd_dashboard_generated_id"
  }
]