constdb=newFirestore();letcollectionRef=db.collection("beans");awaitcollectionRef.add({name:"Kahawa coffee beans",type:"arabica",description:"Information about the Kahawa coffee beans.",embedding_field:FieldValue.vector([0.1,0.3,...,0.2]),// a vector with 768 dimensions});
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[],[],null,["# Get started with generative AI\n==============================\n\nThis page helps you get started with implementing generative AI features in your\napp. It describes the features and integrations for Firestore that involve\ngenerative AI.\n\nQuickstart for vector search with Firestore\n-------------------------------------------\n\nCreating innovative AI-powered solutions for use cases such as product\nrecommendations and chatbots often requires vector similarity search, or vector\nsearch for short. You can perform vector search on Firestore data without the\nhassle of copying data to another vector search solution, maintaining\noperational simplicity and efficiency.\n\nThe core workflow for vector search in Firestore consists of 4 steps.\n\n[Understand vector search fully in our blog post](//cloud.google.com/blog/products/databases/get-started-with-firestore-vector-similarity-search)\n\n### looks_oneGenerate\nvector embeddings\n\nThe first step in utilizing vector search is to generate vector embeddings.\nEmbeddings are representations of different kinds of data like text, images,\nand video that capture semantic or syntactic similarities between the entities\nthey represent. Embeddings can be calculated using a service, such as the\nVertex AI text-embeddings API.\n\n### looks_twoStore\nembeddings in Firestore\n\nOnce the embeddings are generated you can store them in Firestore using one of\nthe supported SDKs. Here is what that operation looks like in the NodeJS SDK: \n\n const db = new Firestore();\n let collectionRef = db.collection(\"beans\");\n await collectionRef.add({\n name: \"Kahawa coffee beans\",\n type: \"arabica\",\n description: \"Information about the Kahawa coffee beans.\",\n embedding_field: FieldValue.vector([0.1, 0.3, ..., 0.2]), // a vector with 768 dimensions\n });\n\n### looks_3Create\na vector index\n\nThe next step is to create a Firestore KNN vector index where the vector\nembeddings are stored. During the preview release, you will need to create the\nindex using the `gcloud` command line tool.\n\n### looks_4Perform\nthe vector search\n\nOnce you have added all the vector embeddings and created the vector index, you\nare ready to run the search. You will then utilize the `find_nearest` call on a\ncollection reference to pass the query vector embedding with which to compare\nthe stored embeddings and to specify the distance function you want to utilize.\n\nOnce again, explore the workflow and more use cases in our [blog post](//cloud.google.com/blog/products/databases/get-started-with-firestore-vector-similarity-search).\n\nSolution: vector search\n-----------------------\n\n**Summary:** Store and query vector embeddings.\n\n**Use case:** This feature is used by the other tools and features.\n\n[See the guide for vector search](//cloud.google.com/firestore/docs/vector-search)\n\nSolution: extension for vector search with Firebase\n---------------------------------------------------\n\n**Summary:** Use the Firebase extension to automatically embed and query your\nFirestore documents with the vector search feature.\n\n**Use case:** Perform automatic vector search in your Firebase projects.\n\n[Review the extension description](//extensions.dev/extensions/googlecloud/firestore-vector-search)\n\nSolution: LangChain integrations\n--------------------------------\n\n**Summary:** Use Firestore as a vector store, document loader, or chat message\nhistory source for LangChain.\n\n**Use case:** Build generative AI applications or retrieval-augmented generation\n(RAG) workflows.\n\n[See the guide for LangChain](//cloud.google.com/firestore/docs/langchain)\n\nSolution: Genkit\n----------------\n\n**Summary:** Genkit is an open source framework that helps you build,\ndeploy, and monitor production-ready AI-powered apps.\n\n**Use case:** Use Genkit and Firestore to create apps that generate\ncustom content, use semantic search, handle unstructured inputs, answer\nquestions with your business data, and much more!\n\n[See the Genkit documentation](//firebase.google.com/docs/genkit)"]]