在沙发上的键空间上没有可用的索引

问题描述 投票:0回答:1

我有一个存储文档的沙发数据库,​​例如

{
  "_host": {
    "kind": "KIND1",
    "id": "ID1",
..
}

我已创建此索引:

CREATE INDEX `kind-id-index` ON `dev`(`_host.kind`,`_host.id`)

但是当我使用此查询时

@Query("#{#n1ql.selectEntity} where _host.kind=$1 and _host.id=$2 ")

我收到此错误:

No index available on keyspace dev_wk_state that matches your query.
couchbase n1ql spring-data-couchbase couchbase-java-api
1个回答
0
投票

背tick在错误的位置。索引必须如下。

CREATE INDEX `kind-id-index` ON `dev`(`_host`.`kind`,`_host`.`id`);

或由于字段中没有特殊字符,因此您可以省略回勾号。

CREATE INDEX `kind-id-index` ON `dev`(_host.kind,_host.id);

仅供参考:_host是对象,种类是对象中的字段(嵌套)。您以_host.kind或`_host`.`kind引用。如果您执行_host.kind,则查找字段“ _host.kind”不是子对象。

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}
}
© www.soinside.com 2019 - 2024. All rights reserved.