我在 Firestore 中有用户生成的数据。对于全文搜索功能,我正在尝试使用弹性应用搜索。我想部署 Cloud 功能,因此每当在 Firestore 中写入文档时,都需要触发一个函数,然后该函数将索引该文档。
const functions = require("firebase-functions");
const admin = require("firebase-admin");
const axios = require("axios");
admin.initializeApp(functions.config().firebase);
exports.createBPS = functions.firestore
.document("MyCollection/{docId}")
.onWrite((snap, context) => {
axios.post(
"https://myapp.ent.us-west1.gcp.cloud.es.io/api/as/v1/engines/myengine/documents?auth_token=private-aadsafdsfadsfdsafdafd",
snap.after.data()
);
});
任何帮助将不胜感激。我正在使用以下 Flutter Firebase Elastic App Search 开发移动应用程序
firestore 中的示例文档 {"id":"1234566", "name": "My name", "description": "My description" 等...}