Builder IO Query Builder Issues with `elemMatch` and returning consistent results

Please fill out as many of the following questions as possible so we can help you promptly! If you don’t know how to answer or it does not apply, feel free to remove it or leave it blank.

Builder content link
e.g. Builder.io: Visual Development Platform
Builder.io: Visual Development Platform

Builder public api key
go to Builder.io: Visual Development Platform and copy your PUBLIC api key
e2f096ba17f74dfd9c140ac050f349a4

What are you trying to accomplish
e.g. I want to integrate builder on a landing page
I would like to use the query builder in builder UI to create an iterate on a custom component based on the existence of “categories”. Basically, I have a blog post and want to show related posts sharing the same category but I cannot get the query right nor can I get it right within the builder IO query builder.

Code stack you are integrating Builder with
e.g. NextJS, react, Shopify
NextJS

Reproducible code example
If you are having integration errors, please link to codesandbox or copy and paste your problematic code here. The more detail the better!

The query body I have tried in code is this:

await builder.getAll('blog-article', {
    query: {
      id: {
        $ne: 'c02f92634815400abfdaedb72b4c9ec0',
      },
      data: {
        categories: {
          $elemMatch: {
            category: {
              id: {
                $in: ['59af3be58ce34979b22f1c4ab68649c4'],
              },
            },
          },
        },
      },
    },
  });

I have tried various permutations of this and still get 0 results (I expect 1 based on the existence of one other blog-article that exists with the same category. If I can get this to return appropriately, then I would then need to figure out how to do it in builder’s page builder if possible.

@kacey You can find an example and test your query at https://builder.io/api-explorer