0

我遇到了一个我似乎没有找到解决方案的问题,而且它看起来真的很奇怪,因为我已经用官方的 Spring Data Couchbase 文档尝试了我所能做的一切。

基本上我想做的只是一个简单的 count() 方法。

我的存储库:

public interface ICourrierRepository extends CrudRepository<Courrier, String> {

List<Courrier> findByCategorie(String categorie);

Long countByCategorie(String categorie);

@View(designDocument = "_design/courrier", viewName = "courrierBase")
long count();

}

视图设置如下:http: //img15.hostingpics.net/pics/169793Capture.png

视图地图是这样的:

function (doc, meta) {
  if (doc._class == "com.model.Courrier") {
    emit(meta.id, null);
  }
}

最糟糕的是,当我在 CouchBase GUI 中将“减少”设置为“_count”时,它实际上可以工作,但是当我从客户端启动它时,我总是收到相同的消息,并且返回为 0:

[cb-computations-2] INFO  c.c.c.java.view.ViewRetryHandler - Received a View HTTP response code (400) I did not expect, not retrying.

谢谢你的帮助...

4

1 回答 1

1

我实际上发现了问题......它来自这一行:

@View(designDocument = "_design/courrier", viewName = "courrierBase")

应该是

@View(designDocument = "courrier", viewName = "courrierBase")

此外,应将视图设置为减少:_count。

希望这对未来的用户有所帮助!

于 2016-03-01T09:54:11.967 回答