在 CouchDB 中基于未知对象键创建和查询芒果索引

Create and query mango index on unknown object key in CouchDB

我有以下对象:

{
  "roleAttribution": {
    "15497490976600-51042": {
      "teams": [
        "e5abb1e962e11a84ff0e41e99103cd90"
      ],
      "persons": [
        "15124323582330-17269"
      ]
    }
  },
  "type": "link",
}

并且需要index/query teams数组。问题是 roleAttribution 键是不可预测的。

有没有一种方法可以索引和查询对象的所有可能的键,直到 teams 数组?

此时,CouchDB 不支持仅索引数组的好方法。 (https://issues.apache.org/jira/browse/COUCHDB-2867). You would need to create a view for that. If you would like to query documents based on the values of team array, you would need to iterate over the array in view map function and emit all the values there. More info about the views here http://guide.couchdb.org/draft/views.html