【问题标题】:IN query in cloud firestore云 Firestore 中的 IN 查询
【发布时间】:2019-09-03 20:04:27
【问题描述】:

我可以在 firestore 中查询多个关键字吗?如何匹配 firestore 中的一组关键字?

我有一个带有标题的文档集合,我想查询包含特定关键字的文章。

以下是我的文档结构。

{
    "users": {
        "user_id_1": {
            "username": "user one",
            "profile_pic": "some_url",
                "articles": {
                    "article_id_1": {
                        "title": "Firebase is so cool",
                        "comments": {
                        "comment_id_1": "First comment",
                        "comment_id_2": "I like trains"
                        }
                    },
                    "article_id_2": {
                        "title": "Firestore rocks!",
                        "comments": {
                        "comment_id_1": "SQL it's better",
                        "comment_id_2": "Do you know the wae?"
                        }
                    },
                    "article_id_3": {
                        "title": "Firestore awesome",
                        "comments": {
                        "comment_id_1": "SQL it's better",
                        "comment_id_2": "Do you know the wae?"
                        }
                    },
                    "article_id_4": {
                        "title": "Firestore is easy",
                        "comments": {
                        "comment_id_1": "SQL it's better",
                        "comment_id_2": "Do you know the wae?"
                        }
                    }
            }
        }
    }
}

这里我想根据以下关键字搜索文章。

["cool", "rocks", "Firestore is easy"]

我应该得到 article_id_1、article_id_2 和 article_id_4

谢谢。

【问题讨论】:

  • 您可能希望编辑您的问题,以更好地说明文档的内容,以及您希望针对该数据执行的查询类型,并获得预期的结果。
  • @DougStevenson - 我已经添加了文档结构。谢谢!

标签: firebase google-cloud-firestore


【解决方案1】:

单独使用 Firestore 是不可能的。它不是文本搜索引擎。您需要将数据导出到 Algolia 等文本搜索引擎,以便执行不基于简单文本相等性的文本搜索。 documentation 建议使用此解决方案。

【讨论】:

    猜你喜欢
    • 2021-05-13
    • 1970-01-01
    • 1970-01-01
    • 2020-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 2021-04-05
    相关资源
    最近更新 更多