【问题标题】:How to index data from Firebase Firestore to Elastic App Search using Cloud Function?如何使用 Cloud Function 将数据从 Firebase Firestore 索引到 Elastic App Search?
【发布时间】:2021-09-28 17:14:30
【问题描述】:

我在 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()
      );
});

任何帮助将不胜感激。我正在使用以下内容开发移动应用程序 扑 火力基地 弹性应用搜索

firestore 中的示例文档 {"id":"1234566", "name": "My name", "description": "My description" 等...}

【问题讨论】:

    标签: firebase flutter google-cloud-firestore google-cloud-functions elastic-appsearch


    【解决方案1】:

    我会推荐使用官方的 ES SDK。这将使您的代码更加稳定和易于阅读。

    Here 是一个安装说明,here 是一个简单的例子。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-10-08
      • 1970-01-01
      • 2012-02-15
      • 1970-01-01
      • 1970-01-01
      • 2021-06-19
      • 1970-01-01
      相关资源
      最近更新 更多