如何在Couchdb 2.0中索引数组字段

时间:2019-07-11 21:28:24

标签: couchdb

我想索引一个数组字段,我有下一个JSON

{
    "id": "invoice1",
    "sellers": [{
        "names": "Clark",
        "items": [{
            "iditem": "item1",
            "properties": [{
                "width": "212cm"
            }]
        }]
    }]
}

我想创建一个宽度索引,我已经在

中使用过create index
{
   "index": {
      "fields": [
         "sellers.[].items.[].properties.[].width"
      ]
   },
   "type": "json"
}

这是很多帖子中的答案,但是当我创建上述索引并查询选择器时

{
   "selector": {
      "sellers": {
         "$elemMatch": {
            "items": {
               "$elemMatch": {
                  "properties": {
                     "$elemMatch": {
                        "width": {
                           "$eq": "212cm"
                        }
                     }
                  }
               }
            }
         }
      }
   }
}

响应为

"warning": "no matching index found, create an index to optimize query time"

0 个答案:

没有答案