代码之家  ›  专栏  ›  技术社区  ›  lurning too koad

如何创建包含映射的复合索引?

  •  0
  • lurning too koad  · 技术社区  · 7 年前

    我有一个集合,其中包含三个属性,我希望为其创建一个复合索引,但始终会得到一个错误,该错误表示我需要此查询的复合索引。这是收集数据模型:

    active: boolean
    date: string
    nameComponents: map
        "nameComponent": boolean
    

    文档的外观如下:

    active: true
    date: "2019-02-18"
    nameComponents:
        "pineapple": true
        "pie": true
    

    查询如下所示:

    Firestore.firestore().collection("someCollection").whereField("active", isEqualTo: true).whereField("nameComponents.pineapple", isEqualTo: true).whereField("date", isLessThanOrEqualTo: "2019-12-31").whereField("date", isGreaterThanOrEqualTo: "2019-01-01")
    

    我创建了以下复合索引,但没有任何运气:

    活动:升序,日期:升序,名称组件:升序

    如何为此查询创建复合索引?在调试器中创建复合索引的链接总是,因为总是,把我带到一个说未知错误的网页。

    1 回复  |  直到 7 年前
        1
  •  0
  •   lurning too koad    7 年前

    更新:很遗憾,这是不可能的。复合索引要求映射中的每个键都有自己的索引。而且,由于FireStore限制了数据库(而不是集合)中允许的复合索引的数量,这绝对是大型地图的反模式。