我在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",
背tick在错误的位置。索引必须如下。由于字段中没有特殊字符,因此您也可以省略回勾号。
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}
}