I using Firebase as my data store. I have a Firestore data structure where documents in a parent collection ("organizations") contain a subcollection ("rags") that stores text chunks along with their corresponding vector embeddings.
I want to create a retriever that efficiently fetches the most relevant documents from a specific organization's "rags" subcollection.
Here's a simplified version of my current code:
const retrieverConfig = defineFirestoreRetriever({
name: 'retriever',
firestore: firestore,
collection: 'organizations',
...options,
embedder: textEmbeddingGecko
})
This won't retrieve the vectors from the subcollection since it is only looking at the parent collection 'organizations'.
How do I create a custom retriever to query the subcollection?
It's likely that you can use the same syntax to locate a subcollection as you would with the Firestore SDK (on any client platform) by providing a delimited path to the subcollection:
collection: 'organizations/DOCID/SUBCOLLECTION'
Where DOCID is the unique document ID in the organizations collection, and SUBCOLLECTION is the name of the nested subcollection under that document.