'm trying to make a query in a Couchbase Database. The idea is to retrieve the elements which are in the range of two numbers. I’m using Spring Data Couchbase.
My document looks like this:
{
“salons”: [
{
“name”: “salon_0”,
“id”: “salon-00”,
“maxAge”: 6,
“minAge”: 3
}
],
“docType”: “com.rccl.middleware.engine.repository.model.salon”
}
The query I’m trying to do is:
@Query("#{n1ql electEntity} WHERE #{n1ql ilter} AND $age BETWEEN minAge AND maxAge ")
Optional findByMinAgeAndMaxAge(@Param(“age”) int age)
But I’m getting the next issues:
Unable to execute query due to the following n1ql errors: {"msg":"No index available on keyspace bucketEx that matches your query. Use CREATE INDEX or CREATE PRIMARY INDEX to create an index, or check that your expected index is online.","code":4000}
This is the query shown in the console:
SELECT META(
bucketEx
).id AS _ID, META(bucketEx
).cas AS _CAS,bucketEx
.* FROMbucketEx
WHEREdocType
= "com.rccl.middleware.engine.repository.model.salon" AND $age BETWEEN minAge AND maxAge “,”$age":7,“scan_consistency”:“statement_plus”}
I tried to create the index, but I get the next error message:
“code”: 5000,
“msg”: “GSI CreateIndex() - cause: Fails to create index. There are not enough indexer nodes to create index with replica count of 1. Some indexer nodes may be marked as excluded.”
I added more than 100 nodes to this document, but I continue getting the same message.
There is something wrong with the query and the index creation? I must to create these indexes or there is another way to make this query?
Thanks a lot.