0

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?

2

2 Answers 2

0

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you so much Alex. Seems I need to create a firestore database with enterprise edition and test there by writing query.
Hey there. Did my answer help? Can I help you with other information?
Sure Alex, please go ahead.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.