<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/understanding-collection-group-queries-in-cloud-firestore-qq1xm1mdo" -->

---
title: Understanding Collection Group Queries in Cloud Firestore
description: Collection group queries in Cloud Firestore, announced at Google I/O, let developers query across multiple subcollections that share the same name instead of...
canonical: https://daily.dev/posts/understanding-collection-group-queries-in-cloud-firestore-qq1xm1mdo
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Understanding Collection Group Queries in Cloud Firestore | daily.dev
og:description: Collection group queries in Cloud Firestore, announced at Google I/O, let developers query across multiple subcollections that share the same name instead of...
og:url: https://daily.dev/posts/understanding-collection-group-queries-in-cloud-firestore-qq1xm1mdo
og:image: https://api.daily.dev/og/posts/QQ1XM1mDO.png
og:image:alt: Understanding Collection Group Queries in Cloud Firestore
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Understanding Collection Group Queries in Cloud Firestore

**[Firebase](https://daily.dev/sources/firebase-blog)** · 8 min read · 0 upvotes · 0 comments

## Summary

Collection group queries in Cloud Firestore, announced at Google I/O, let developers query across multiple subcollections that share the same name instead of being limited to a single collection. The Q&A format covers how to enable the required index (via console or by catching the SDK error and following its generated URL), pitfalls like naming collisions across differently-purposed collections with the same name, the need for version 2 security rules with recursive wildcards to properly scope query permissions, the 200 index exemption limit per database, and how to decide between subcollections and flat top-level collections based on query patterns and indexing needs.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://firebase.blog/posts/2019/06/understanding-collection-group-queries>

## Questions this post answers

### What is a collection group query in Cloud Firestore and why would I use one?

A collection group query lets you query across all collections in a Firestore database that share the same name, rather than being restricted to a single collection. For example, if every restaurant document has a reviews subcollection, a collection group query on 'reviews' can find all reviews written by a particular author across every restaurant, which was not possible before this feature.

_Developers designing Firestore data models track feature rollouts like this on daily.dev to plan schema decisions early._

### How do I set up an index for a Firestore collection group query?

Write the collectionGroup() query in code and run it; the client SDK returns an error with a URL that opens the Firebase Console directly to create the needed index. Alternatively, manually create it under the Cloud Firestore Index tab, Single Field section, by adding an exemption for the collection name and field with collection group scope, then enabling ascending or descending indexes.

_Anyone debugging Firestore index errors can keep query and indexing tips like these close on daily.dev._

### Why does my Firestore security rule fail on a collection group query even though it matches my documents?

Firestore must verify a query is allowed by security rules without inspecting the actual data, so a rule written for one path like restaurants/reviews cannot guarantee a collection group query on 'reviews' only touches that path, since other collections like couriers/reviews could share the name. The fix is a recursive wildcard rule matching any path ending in 'reviews', which requires version 2 of Firestore's security rules.

_Teams hardening Firestore security rules can follow gotchas like this via daily.dev before shipping to production._

## Similar posts on daily.dev

- [How Firestore Structures Data and How to Perform CRUD Operations With It](https://daily.dev/posts/how-firestore-structures-data-and-how-to-perform-crud-operations-with-it-odioykply) · freeCodeCamp · 1 upvotes · 0 comments
- [New Firestore query engine enables pipelines](https://daily.dev/posts/new-firestore-query-engine-enables-pipelines-qveysfcui) · Google Cloud · 0 upvotes · 0 comments
- [Firestore Adds Pipeline Operations with Over 100 New Query Features](https://daily.dev/posts/firestore-adds-pipeline-operations-with-over-100-new-query-features-dm1dqw0jf) · InfoQ · 0 upvotes · 0 comments

---

Tags: [#backend](https://daily.dev/tags/backend), [#firebase](https://daily.dev/tags/firebase), [#nosql](https://daily.dev/tags/nosql), [#firestore](https://daily.dev/tags/firestore)

[View this post on daily.dev](https://daily.dev/posts/understanding-collection-group-queries-in-cloud-firestore-qq1xm1mdo)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Understanding Collection Group Queries in Cloud Firestore","url":"https://daily.dev/posts/understanding-collection-group-queries-in-cloud-firestore-qq1xm1mdo","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/understanding-collection-group-queries-in-cloud-firestore-qq1xm1mdo"},"datePublished":"2026-08-23T12:17:39.175Z","dateModified":"2026-08-24T06:51:19.852Z","description":"Collection group queries in Cloud Firestore, announced at Google I/O, let developers query across multiple subcollections that share the same name instead of...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7ed721de96163685d26ab7e314be3ebc?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7ed721de96163685d26ab7e314be3ebc?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Firebase","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Firebase","logo":"https://media.daily.dev/image/upload/s--i395oqZH--/f_auto,q_auto/v1787487448/logos/firebase-blog?_a=BAMAMicg0","url":"https://daily.dev/sources/firebase-blog"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/understanding-collection-group-queries-in-cloud-firestore-qq1xm1mdo","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"backend,firebase,nosql,firestore","timeRequired":"PT8M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Firebase","item":"https://daily.dev/sources/firebase-blog"},{"@type":"ListItem","position":3,"name":"Understanding Collection Group Queries in Cloud Firestore"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/understanding-collection-group-queries-in-cloud-firestore-qq1xm1mdo#faq","mainEntity":[{"@type":"Question","name":"What is a collection group query in Cloud Firestore and why would I use one?","acceptedAnswer":{"@type":"Answer","text":"A collection group query lets you query across all collections in a Firestore database that share the same name, rather than being restricted to a single collection. For example, if every restaurant document has a reviews subcollection, a collection group query on 'reviews' can find all reviews written by a particular author across every restaurant, which was not possible before this feature. Developers designing Firestore data models track feature rollouts like this on daily.dev to plan schema decisions early."}},{"@type":"Question","name":"How do I set up an index for a Firestore collection group query?","acceptedAnswer":{"@type":"Answer","text":"Write the collectionGroup() query in code and run it; the client SDK returns an error with a URL that opens the Firebase Console directly to create the needed index. Alternatively, manually create it under the Cloud Firestore Index tab, Single Field section, by adding an exemption for the collection name and field with collection group scope, then enabling ascending or descending indexes. Anyone debugging Firestore index errors can keep query and indexing tips like these close on daily.dev."}},{"@type":"Question","name":"Why does my Firestore security rule fail on a collection group query even though it matches my documents?","acceptedAnswer":{"@type":"Answer","text":"Firestore must verify a query is allowed by security rules without inspecting the actual data, so a rule written for one path like restaurants/reviews cannot guarantee a collection group query on 'reviews' only touches that path, since other collections like couriers/reviews could share the name. The fix is a recursive wildcard rule matching any path ending in 'reviews', which requires version 2 of Firestore's security rules. Teams hardening Firestore security rules can follow gotchas like this via daily.dev before shipping to production."}}]}
```

