资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

CouchbaseView-创新互联

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

创新互联建站-专业网站定制、快速模板网站建设、高性价比保亭黎族网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式保亭黎族网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖保亭黎族地区。费用合理售后完善,十年实体公司更值得信赖。
  • 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

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


文章标题:CouchbaseView-创新互联
文章链接:http://cdkjz.cn/article/coiohg.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220