No index available on keyspace businessparameters

n1ql

#1

{
“id”: “1234”,
“availableTo”: [
“price1”,
“policy”
]
}

when i run the below query , i get the error given below
SELECT price.id FROM price UNNEST price.availableTo AS availableto WHERE availableto=“price1”

Error: No index available on keyspace price that matches your query

I am creating the index as below
create index index_availableTo on price(availableTo)

Could someone please suggest how to write the index for the above scenario.


#2

AvailableTo is Array if you need to search inside array create array Index

CREATE INDEX ix1 ON price (DISTINCT availableTo, id);
SELECT id FROM price WHERE ANY v IN availableTo SATISFIES v = "price" END;

https://developer.couchbase.com/documentation/server/current/n1ql/n1ql-language-reference/indexing-arrays.html


#3
It is not working could you please suggest something else. I am still getting below error

[
  {
    "code": 4000,
    "msg": "No index available on keyspace price that matches your query. Use CREATE INDEX or CREATE PRIMARY INDEX to create an index, or check that your expected index is online.",
    "query_from_user": "SELECT id FROM price WHERE ANY v IN availableTo SATISFIES v = \"price\" END;"
  }
]

#4

Above statement should work.
Provide me output of
select * from system:indexes;


#5

It worked for me if i create index as below
CREATE INDEX idx_sched ON price ( DISTINCT ARRAY v FOR v IN availableTo END );

Thanks a lot