SELECT FROM myIndex WHERE a=1 AND b=2 AND c=3

Awesome post, @pier!

It can get complex, but you can build an intersection query with a bunch of conditionals. Here is a similar discussion:

One basic formula could be to create a UDF along these lines

CreateFunction({
  name: 'search_comments',
  body: Query(
    Lambda(
      ['a', 'b', 'c'],
      Let(
        {
          with_a: If(
            IsNull(Var('a')),
            [],
            [Match(Index('index_a'), Var('a'))]
          ),
          with_b: If(
            IsNull(Var('b')),
            Var('with_a'),
            Append(Var('with_a'), [
              Match(Index('index_b'), Var('b'))
            ])
          ),
          with_c: If(
            IsNull(Var('c')),
            Var('with_b'),
            Append(Var('with_b'), [
              Match(Index('index_c'), Var('c'))
            ])
          ),
          // keep repeating for more options
          // ...
          computed_set: If(
            IsEmpty(Var('with_c')),
            Documents(Collection('things')), // simplify if no filters
            Intersection(Var('with_c'))
          )
        },
        Paginate(Var('computed_set'))
      )
    )
  )
})
4 Likes