Firestore is a serverless document-oriented database that scales to meet any demand. Extend your database application to build AI-powered experiences leveraging Firestore’s LangChain integrations.This notebook goes over how to use Firestore to store vectors and query them using the
FirestoreVectorStore class.
Before You Begin
To run this notebook, you will need to do the following: After confirmed access to database in the runtime environment of this notebook, filling the following values and run the cell before running example scripts.🦜🔗 Library Installation
The integration lives in its ownlangchain-google-firestore package, so we need to install it. For this notebook, we will also install langchain-google-genai to use Google Generative AI embeddings.
☁ Set Your Google Cloud Project
Set your Google Cloud project so that you can leverage Google Cloud resources within this notebook. If you don’t know your project ID, try the following:- Run
gcloud config list. - Run
gcloud projects list. - See the support page: Locate the project ID.
🔐 Authentication
Authenticate to Google Cloud as the IAM user logged into this notebook in order to access your Google Cloud Project.- If you are using Colab to run this notebook, use the cell below and continue.
- If you are using Vertex AI Workbench, check out the setup instructions here.
Basic Usage
Initialize FirestoreVectorStore
FirestoreVectorStore allows you to store new vectors in a Firestore database. You can use it to store embeddings from any model, including those from Google Generative AI.
from_texts and from_documents method.
Delete Vectors
You can delete documents with vectors from the database using thedelete method. You’ll need to provide the document ID of the vector you want to delete. This will remove the whole document from the database, including any other fields it may have.
Update Vectors
Updating vectors is similar to adding them. You can use theadd method to update the vector of a document by providing the document ID and the new vector.
Similarity Search
You can use theFirestoreVectorStore to perform similarity searches on the vectors you have stored. This is useful for finding similar documents or text.
filters parameter. This is useful for filtering by a specific field or value.
Customize Connection & Authentication
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.