Firestore has query limitation with max 30 filter parameters in a single query. Recently, Google has announced that, Firestore Enterprise has MongoDB compatibility. Now, if we use MongoDB query in Firestore, will the filter parameter limitation be imposed on that query?
-
I would suggest either try by yourself, or open a support ticket at Google or maybe review your query. 30 filter parameter sounds ridiculous to me.Wernfried Domscheit– Wernfried Domscheit2025-05-21 08:19:01 +00:00Commented May 21 at 8:19
-
@WernfriedDomscheit cloud.google.com/firestore/native/docs/query-data/… cloud.google.com/firestore/native/docs/query-data/…blueDexter– blueDexter2025-05-21 08:32:53 +00:00Commented May 21 at 8:32
2 Answers
Firestore has query limitation with max 30 filter parameters in a single query.
Yes, that's correct. You can combine up to 30 clauses when using in, not-in, and array-contains-any operators. The same limitations apply when using the OR clause.
Recently, Google has announced that, Firestore Enterprise has MongoDB compatibility.
That's also correct. According to the official documentation:
Firestore with MongoDB compatibility enables developers to use existing MongoDB application code, drivers, tools, and the open-source ecosystem of MongoDB integrations with Firestore.
Firestore provides a MongoDB compatible API allowing you to use Firestore as the database for your existing MongoDB applications.
But that doesn't mean that the Firestore limitation won't apply anymore. However, in the below documentation for the Enterprise edition:
It is said that:
Enterprise edition (Preview): builds on the Standard edition and offers additional capabilities including MongoDB compatibility and a new advanced query engine supporting a larger number of features and increased limits.
But it doesn't refer to some specific limits that are increased. So I personally recommend you take into consideration the actual limits and do some tests yourself as also @WernfriedDomscheit mentioned in his comment.
3 Comments
Seems, the filter query limitation is gone with the Firestore Enterprise edition MongoDB compatible.
I created a Firestore Enterprise edition database using a billing account in Google Cloud Platform.
I created a sample collection employees inside that database and populate the collection with some test documents.
db.employees.find({
name: { $in: ["name1", "name2", "name3", "name4", "name5", "name6", "name7", "name8", "name9", "name10", "name11", "name12", "name13", "name14", "name15", "name16", "name17"]},
tags: { $nin: ["tag1", "tag2", "tag3", "tag4"]},
age: { $gt: 20, $lt: 60},
distance: { $gt: 2, $lt: 20}
});
This query contains 17 * 4 * 2 * 2 = 272 filter parameters.
17 filter parameters passed for name.4 filter parameters passed for tags.
2 filter parameters passed for age.
2 filter parameters passed for distance.
In standard edition, we would have used max 30 filter query parameters in combination. But with the new Enterprise edition, the filter query limitation is gone.