Couchbase View
admin
2023-02-08 03:20:05
0

Couchbase index: called view -- virtually another document build via map-reduce function

  • Map function:
       Call emit() to generate a key-value pair

  • Reduce function:
       Optional (disabled by reduce=false)
       Used to calculate count, sum etc

 

Query View:

  • Call ViewResult.success() to check whether view execution is successful. Call ViewResult.error()  to see error details

  • Set ViewQuery.debug(true) generate statistics information. Retrieved by  ViewResult.debug()

  • Remember to call ViewQuery.development(true) if a development View has not been published as production view

  • For dev mode, full design doc name is:    _design/dev_[designdoc name],  to query it, just use designdoc name
       If you specify  designdoc name as dev_xxx, you get error:
       com.couchbase.client.java.error.ViewDoesNotExistException: View does not exist
       If you specify designdoc name as  /dev_xxx or  _design/dev_xxx, you get error:
       {"error":"bad_request","reason":"p_w_uploads not supported in Couchbase"}

  • To query composite key, do not use ViewQuery.key(String),  which causes additional quote to be added to the key, add get a json format error:
        invalid UTF-8 JSON  {error,garbage_after_value}
    Uses ViewQuery.key(JsonArray) and JsonArray.from(Object[] array). Each element of array must of correct type (String or Long)

  • To view complete query as url parameter after encoding:  use ViewQuery.toString()

  • Suppose a view composes of 3 field [a, b, c],   it is possible to find documents by  [a, b] only and [a, c] only using that view.  ViewQuery.startKey([a, b, null])  and ViewQuery.startKey([a, null, c])

  • Sort query result:  ViewQuery.desc()

  • References:
    http://docs.couchbase.com/admin/admin/Views/views-writing.html
    http://docs.couchbase.com/admin/admin/Views/views-querySample.html

 

Bulk operations:

  • Couchbase java sdk supports bulk operation, which improves performance for read/write for a number of documents

  • References:
    http://docs.couchbase.com/developer/java-2.1/documents-bulk.html

相关内容

热门资讯

我来教教您“云圈丰城麻将.是不... 您好:云圈丰城麻将这款游戏可以开挂,确实是有挂的,需要了解加客服微信【4282891】很多玩家在这款...
玩家攻略科普“中至上饶麻将.到... 家人们!今天小编来为大家解答中至上饶麻将透视挂怎么安装这个问题咨询软件客服徽9784099的挂在哪里...
玩家攻略科普“聚友互娱.到底有... 网上科普关于“聚友互娱有没有挂”话题很是火热,小编也是针对聚友互娱作*弊开挂的方法以及开挂对应的知识...
资本回归理性,无人物流车赛道融... 白犀牛新一轮融资刚宣布不久,菜鸟拟入股九识智能的消息日前被媒体爆出。表面上看,无人物流车赛道今年成为...
终于了解“杭州麻将.怎么开挂?... 家人们!今天小编来为大家解答杭州麻将透视挂怎么安装这个问题咨询软件客服徽4282891的挂在哪里买很...
最新引进“新版wepoker.... 家人们!今天小编来为大家解答新版wepoker透视挂怎么安装这个问题咨询软件客服徽4282891的挂...
【第一财经】“欢乐贰柒拾.怎么... 有 亲,根据资深记者爆料欢乐贰柒拾是可以开挂的,确实有挂(咨询软件无需打...
终于了解“喜扣游戏.怎么开挂?... 家人们!今天小编来为大家解答喜扣游戏透视挂怎么安装这个问题咨询软件客服徽9784099的挂在哪里买很...
玩家分享攻略“美味冰淇淋.到底... 家人们!今天小编来为大家解答美味冰淇淋透视挂怎么安装这个问题咨询软件客服徽4282891的挂在哪里买...
玩家最新攻略“大富豪app.真... 您好:大富豪app这款游戏可以开挂,确实是有挂的,需要了解加客服微信【9752949】很多玩家在这款...