Is there a way to do AND filtering within an array?

My index contains items with an array of objects.
Let’s say the items are of the form { name, toys } and toys are objects of form { name, count }
I want to filter for items that contain a toy with the name “Teddy bear” and count “3”.

Is there a way to do this? It seems like specifying the filter as (toys.name = “Teddy bear” and count = 3) will also return items that have { toy: “Teddy bear”, count: 2} and { toy: “Bouncy ball”, count: 3 }

@di1 With the way the filtering works, I didn’t see a way to get around this issue. I looked through some older posts and this is a common pain point when using an array of objects.

The workaround is to redesign your record layout to use singular records instead. This toy information could be in a separate index for example.

An example:

toy_boxes.json
[
  {
    "color": "Orange",
    "location": "Playroom 1",
    "sponsor": "Acme Co"
  },
  ...
]

toy_box_toys.json
[
  {
    "boxColor": "Orange",
    "name": "Teddy bear",
    "count": 2
  },
  ...
]

Unfortunately, this does introduce additional records with this design.