我正在从基于 spring boot 的 couchbase 存储库中删除主索引以提高性能。目前,存储库使用@Repository、@N1qlPrimaryIndexed 注释和主索引进行注释,如下所示。SB 版本 - spring-boot-2.1.11.RELEASE。我对 couchbase 索引不太熟悉。
任何查询的主索引
CREATE PRIMARY INDEX primary-index ON Apps WITH {“defer_build”:true};
计划对所有存储库使用@N1qlSecondaryIndexed 方法。能够在 couchbase 实例上本地创建以下二级索引,但是一旦将代码推送到 git 中,jenkins build 总是会失败并出现以下错误。
"{"msg":"No index available on keyspace Apps that matches your query. Use CREATE INDEX or CREATE PRIMARY INDEX to create an index, or check that your expected index is online.","code":4000}"
我们是否需要同时拥有主索引和二级索引?我确认以下二级索引没有错误,并且我能够在 couchbase 实例中本地创建它。
二级索引现在'
CREATE INDEX `idx_fundraising` ON `Apps`(`newterm`, `_class`) WHERE platform = 'UO' WITH {"defer_build":true};
在存储库的顶部,我注释如下。我完全不确定我对这个简单的索引设计或注释的想法有什么问题。我是否需要从数据层实体中捕获所有字段?你能指出我的方法有什么问题吗?
@Repository
@N1qlSecondaryIndexed(indexName = "idx_fundraising")
@ViewIndexed(designDoc = "pool")
有人可以帮助您对此提出想法/意见吗?
谢谢。