在Couchbase中创建索引
系统
我没有创建任何存储桶,因此开始创建存储桶。
描述在此处列出了
现在我尝试运行N1QL命令,并且给我以下错误。
[
{
"code": 4000,
"msg": "No index available on keyspace `default`:`test` that matches your query. Use CREATE PRIMARY INDEX ON `default`:`test` to create a primary index, or check that your expected index is online.",
"query": "select * from test;"
}
]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是预期的行为。没有在Couchbase中自动创建索引,甚至不是主要索引。
您可以使用以下方式创建一个主要索引:
这足以使您的查询工作。有了一个文档,它不会太慢。但是在生产中,您需要创建更好地针对查询量身定制的索引(就像在关系数据库中一样)。
我建议您查看文档以了解有关索引的更多信息。
可能有用的另一个工具是 index顾问。它可以根据您的查询建议更好的索引。单击查询工作台中的“建议”按钮进行尝试。
This is expected behavior. No indexes are created automatically in Couchbase, not even a primary index.
You can create a primary index with:
That's enough to make your query work. With a single document, it won't be too slow. But in production, you'll need to create indexes that are better tailored to your queries (just like in a relational database).
I recommend checking out the documentation to learn more about indexes.
Another tool that can be helpful is the Index Advisor. It can recommend better indexes, based on your query. Click the "Advice" button in Query Workbench to try it out.