Couchbase views allow you to extract specific fields and information from data and create an easily accessible index.
The purpose of a view is to take the unstructured or semi-structured data stored within your Couchbase Server database, extract the fields and information you want, and produce an index of the selected information. Storing information in Couchbase Server using JSON makes the process of selecting individual fields for output easier. The resulting structure that is generated is a view on the stored data. The view that is created during this process lets you iterate, select, and query the information in your database from the raw data objects that have been stored.
Common pitfalls when using views:
- Do not return entire docs using views. Rather, use the “attach doc” flag. Another solution is to emit just the object IDs and then do a parallelized bulk operation to get all of the relevant objects.
- Views work only on data that has been persisted to disk
- Views may return docs with expired TTL
- Publish your view or else you may receive partial data
- Do not use too many views – if you need to use more than 10-15 views, you should instead use N1QL or create a standardized key pattern to access your data via the key
Resources: