使用map reduce的couchbase中的动态视图

问题描述 投票:1回答:1

这是我正在使用的地图缩小功能

  public static final String UNIQUE_ASSET_COUNT_VIEW = "function (doc, meta) { \n"
  + "  if(doc.type == \"nikhil\") { \n"
  + "emit();

我想让它变得动态,因为它会根据文档的类型而改变。现在我无法做到这一点。有没有办法实现这一目标。我正在使用Couchbase 5.x.

java spring couchbase
1个回答
1
投票

视图正在Couchbase中出现,如果你在+ 5.5.x上运行,你应该创建一个索引。

从这个版本开始,我们可以将所有聚合推送到索引:https://blog.couchbase.com/new-querying-features-couchbase-server/

如果您正在使用Spring数据,则可以添加注释@ViewIndexed(如果您确实要使用视图)或@ N1qlPrimaryIndexed。

© www.soinside.com 2019 - 2024. All rights reserved.