Couchbase 中的索引 - 使用主索引而不是辅助索引

Indexing in Couchbase - primary index being used instead of secondary index

我运行在couchbase

中有很多这样的查询
SELECT * FROM dev_hostel  where data.type = 'Guesthouse'and data.id = '12'

所以,我创建了这个索引

CREATE INDEX `type-id-index` ON `dev_hostel`(`data.type`,`data.id`)

但是当我解释查询时,我发现创建的索引没有被使用,但是主索引被使用了

{
  "plan": {
    "#operator": "Sequence",
    "~children": [
      {
        "#operator": "PrimaryScan3",
        "index": "#primary",

反引号位置错误。索引必须如下所示。 由于字段中没有特殊字符,您也可以省略反引号。

CREATE INDEX `type-id-index` ON `dev_hostel`(data.type,data.id);

FYI: _host is object and kind is field(nested) in object. 
You reference as _host.kind or `_host`.`kind`. If you do `_host.kind` it looking field "_host.kind" not sub object. 
If you want reference s1 you must use `f1.f2`.s1 because there is dot in the field you must do `f1.f2`.s1


{
  "_host": {
    "kind": "KIND1",
    "id": "ID1"
     },
  "f1.f2": { "s1": 10}
}

探索指数顾问https://index-advisor.couchbase.com/