在Couchbase中创建索引

发布于 2025-01-25 18:32:10 字数 1093 浏览 3 评论 0 原文

系统

我没有创建任何存储桶,因此开始创建存储桶。

描述在此处列出了

存储桶配置”。

我添加了一个文档

现在我尝试运行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;"
  }
]

System

enter image description here

I have not created any bucket so started creating bucket.

enter image description here

Bucket configuration is listed below.

enter image description here

I added a document
enter image description here

Now i tried to run n1ql command and it give me following error.

[
  {
    "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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

躲猫猫 2025-02-01 18:32:10

这是预期的行为。没有在Couchbase中自动创建索引,甚至不是主要索引。

您可以使用以下方式创建一个主要索引:

CREATE PRIMARY INDEX ON `test`

这足以使您的查询工作。有了一个文档,它不会太慢。但是在生产中,您需要创建更好地针对查询量身定制的索引(就像在关系数据库中一样)。

我建议您查看文档以了解有关索引的更多信息

可能有用的另一个工具是 index顾问。它可以根据您的查询建议更好的索引。单击查询工作台中的“建议”按钮进行尝试。

This is expected behavior. No indexes are created automatically in Couchbase, not even a primary index.

You can create a primary index with:

CREATE PRIMARY INDEX ON `test`

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文