I have a couchbase DB with documents stored, like
{
"_host": {
"kind": "KIND1",
"id": "ID1",
..
}
I have created this index:
CREATE INDEX `kind-id-index` ON `dev`(`_host.kind`,`_host.id`)
but when I use this query
@Query("#{#n1ql.selectEntity} where _host.kind=$1 and _host.id=$2 ")
I got this error:
No index available on keyspace dev_wk_state that matches your query.
The back ticks are at wrong place. The index must be as follows.
CREATE INDEX `kind-id-index` ON `dev`(`_host`.`kind`,`_host`.`id`);
As there is no special characters in the fields you can omit back ticks also.
CREATE INDEX `kind-id-index` ON `dev`(_host.kind,_host.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}
}