我有一个存储文档的沙发数据库,例如
{
"_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.
背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}
}