Problem wth cbq in commandline, how to drop _default or change bucket

How can I change bucket in the cqb prompt ? I currently have this command to get to it:

docker exec -it 26ad6eb65829 /opt/couchbase/bin/cbq -u Administrator -p password -engine=http://127.0.0.1:8091/

Then I run this query on a cluster that has a default and analysis bucket and analysis has additional_data and _default scopes:

SELECT * FROM `analysis`.additional_data.states;

And I get this error message:
{
“requestID”: “516943ff-4585-4ec8-9ff4-4947b4908117”,
“errors”: [
{
“code”: 4000,
“msg”: “No index available on keyspace default:analysis.additional_data.states that matches your query. Use CREATE PRIMARY INDEX ON default:analysis.additional_data.states to create a primary index, or check that your expected index is online.”
}
],
“status”: “fatal”,
“metrics”: {
“elapsedTime”: “942.69µs”,
“executionTime”: “837.37µs”,
“resultCount”: 0,
“resultSize”: 0,
“serviceLoad”: 12,
“errorCount”: 1
}
}

Thanks a lot

You need to create an index of sorts to fetch data - primary if you don’t have any specific filters or secondary if you can apply filters.

If you issue the statement noted in the error, i.e.

CREATE PRIMARY INDEX ON default:analysis.additional_data.states

then you’ll be able to issue the SELECT statement.

Couchbase (in currently released versions) doesn’t support unindexed scanning of the data. See MB-52184

Ref:
https://docs.couchbase.com/server/current/learn/services-and-indexes/indexes/global-secondary-indexes.html
https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/createprimaryindex.html

HTH.

1 Like