"select xrefId, CLSTR, CLUSTER_NAME, SHORTENED_NAME, "
+ "PRMRY, SET_NUM, TYPE from myBucket "
+ "where _class=\"com.package.model.ClusterCodeXref\"
And a corresponding secondary index (I’m not allowed to create a primary index on this bucket for internal reasons):
Definition: CREATE INDEX `idx_xref` ON `myBucket`(`xrefId`,`CLSTR`,`CLUSTER_NAME`,
`SHORTENED_NAME`,`PRMRY`,`SET_NUM`,`TYPE`)
Yet when I run the query (using spring-data-couchbase), I get the following error:
"No index available on keyspace myBucket that matches your query.
Use CREATE INDEX or CREATE PRIMARY INDEX to create an index, or check that your expected index is online."
Leading key of Index needs to be part of the query predicate.
CREATE INDEX `idx_xref` ON `myBucket`(_class, `xrefId`,`CLSTR`,`CLUSTER_NAME`,
`SHORTENED_NAME`,`PRMRY`,`SET_NUM`,`TYPE`)
If you can also change query add xrefId IS NOT MISSING, if it accepatble
CREATE INDEX `idx_xref` ON `default`(_class, `xrefId`,`CLSTR`,`CLUSTER_NAME`, `SHORTENED_NAME`,`PRMRY`,`SET_NUM`,`TYPE`);
EXPLAIN select xrefId, CLSTR, CLUSTER_NAME, SHORTENED_NAME, PRMRY, SET_NUM, TYPE from default where _class="com.package.model.ClusterCodeXref";
I didn’t create it on the default bucket - the document is not stored there. But yes, I recreated the index as you suggested. Explain plan gives me the same error that no index is available.
I’ve been trying in both interfaces. Here’s the index:
CREATE INDEX idx_xref ON API_Resource_WEM(_class,xrefId,CLSTR,CLUSTER_NAME, SHORTENED_NAME,PRMRY,SET_NUM,TYPE) where _class=com.package.model.ClusterCodeXref using GSI;
And here’s the query:
SELECT xrefId, CLSTR, CLUSTER_NAME, SHORTENED_NAME, PRMRY, SET_NUM, TYPE
FROM API_Resource_WEM
WHERE (_class = “com.package.model.ClusterCodeXref”)
CREATE INDEX idx_xref ON API_Resource_WEM(_class,xrefId,CLSTR,CLUSTER_NAME, SHORTENED_NAME,PRMRY,SET_NUM,TYPE)
where _class="com.package.model.ClusterCodeXref" using GSI;