Couchbase View
2015-05-31 10:29
417 查看
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":"attachments 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
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":"attachments 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
相关文章推荐
- NoSQL和Redis简介及Redis在Windows下的安装和使用教程
- 最新统计排名前十的SQL和NoSQL数据库排行榜
- 大数据时代的数据库选择:SQL还是NoSQL?
- PHP对MongoDB[NoSQL]数据库的操作
- MongoDB系列教程(一):NoSQL起源
- NoSQL反模式 - 文档数据库篇
- Asp.Net Couchbase Memcached图文安装调用开发
- 纯Python开发的nosql数据库CodernityDB介绍和使用实例
- mongodb常遇到的错误。
- ledisdb作为嵌入式存储引擎入门例程
- redis概述
- 如何高效地将SQL数据映射到NoSQL存储系统中
- NoSQL的现状
- 5款主流NoSQL数据库全方位横评
- HBase技术介绍
- NoSQL 纪要
- monogdb语句学习大全(助你快速熟悉并且掌握)
- redis 认识 与普通SQL
- 值得尝试的10款出色NoSQL数据库
- Aerospike-Architecture系列之系统概述