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

Json Couchbase中的索引-使用主索引而不是辅助索引,json,couchbase,explain,n1ql,database-indexes,Json,Couchbase,Explain,N1ql,Database Indexes,我在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

我在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}
}

探索索引顾问

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

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}
}
探索索引顾问