couchbase java view_Couchbase 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值