What's the maximum number of terms allowed for an $in or $nin metadata filter query?

Background

We have an indexed metadata field called group. The cardinality of the field is 10,000. We need the ability to query vectors that only match some group values, so we’re using the $in operator as per:

Problem

The problem is that we need to specify 1,000s of values for the $in set. For example:

{
  "group": {"$in":["a1","a2", ..., "a1000"]}
}

What are the maximum constraints that apply to a query like this? Is there a maximum number of terms that are allowed for the $in set? Is there a maximum byte size for the query? If so what are those limits?

Hi Richie, there is no hard limit on the number of values in your filter. However, there is a 2MB limit on request payload size, so whatever you can fit in there alongside you query vector and other metadata is your actual limit.

Hope that helps!

2 Likes