Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Couchbase View

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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 designdoc 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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report