This document does not exist and will not appear in queries or snapshots, but identically structured document works

This is telling you that territories/6 does not exist as an actual document, whereas territories/7 does.

In Cloud Firestore it is possible to have subcollections owned by "virtual" documents - that is the document at the higher level doesn't exist, but it has children.

These virtual documents can be easy ways to organize information without have to create duplicate dummy documents.

In this case, you've either:

  1. Created a bunch of dispatch documents under territories/6 before you created the territories document, or
  2. You've subsequently deleted territories/6 without deleting the subcollection documents.

Not sure this will resolve your problem but did mine... the message in console: "This document does not exist, it will not appear in queries or snapshots" seems to appear if the document has only subcollections but no fields (I guess this is referred to as "virtual" document).

I used set method to add dummy fields (json objects) on already existing "virtual" documents which made them discoverable by snapshots or queries. It did not overwrite/delete any subcollections of those documents. Fields could not be added via console.

My code:

var docRef = this.fsdb.collection('sessions')
//do for all "virtual" docs in collection
docRef.doc('mySession1').set({dummy: 'dummy'})

docRef.onSnapshot(val => {
   var mySessionsArray: any [] = []
   val.forEach(myDoc => {
    mySessionsArray.push(myDoc.id)
  })
  console.log(mySessionsArray)
})

console: ["mySession1", "mySession2", "mySession3"]

Disclaimer, not a programmer by trade :-)


I was able to fix this bug, the accepted answer currently only explains the why and does not provide a fix. Here is the code that caused the bug (for me) when I attempted to run this without a "users" collection at the root of my Firestore:

db.collection("users").document(currentUserUID).collection("groups").addDocument(data: [
        "groupID": newGroup.documentID,
        "userAddDate": NSDate()
    ])

The currentUserUID document that was created was throwing the 'Document does not exist' virtual bug. I copied the currentUserUID and deleted the users collection and virtual UserUID document.

I then created a new 'users' collection at the root node and pasted in the value I had copied for the userUID with a bogus field.Recreate user root node

Then when I re-ran the above snippet of code, the "groups" collection and document were re-added no problem :)