Questions tagged [couchbase-view]

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:

208 questions
1
vote
0 answers

Bulk get Couchbase API didnt return updated result

I am using bulk_get(/{db}/_bulk_get) API from Couchbase to get bulk documents, below is my code def getBulkJsonDoc(doc_ids): """ @purpose: gets a bulk docs from couchbase """ r = requests.post(base_url + '_all_docs',…
rash
  • 91
  • 7
1
vote
1 answer

Couchbase View : Sorting on Keys

I am using Couchbase 3.0 and I have a use case where I want to perform sorting, but as i cam through couchbase does not provide Sorting on Values but it provides Sorting on Keys, But as I use descending(true) it is returning me empty list. And on…
Shivansh
  • 3,454
  • 23
  • 46
1
vote
1 answer

"invalid char in json text" error in Couchbase view results

This is the my document which i store in the bucket.Also the Id(key) attribute is screenName. { "created": null, "createdBy": null, "updated": null, "updatedBy": null, "screenName": "steelers", "appId":…
Neero
  • 226
  • 2
  • 7
  • 23
1
vote
1 answer

Couchbase compound keys in views with the C SDK

I'm trying to implement a very basic C application that queries a Couchbase view using the C SDK. I got the SDK as such working since I can retrieve data from the DB server and even query views with a range query (startkey and endkey). However, if I…
airtruk
  • 321
  • 3
  • 11
1
vote
2 answers

Why doesn't my couchbase view return data?

I have created sample view in my couchbase 4.0 B version for windows. I also published my view. I am accessing it through java program, but not getting any result, but instead getting some error with json. Here is the full code of what I am…
1
vote
1 answer

Filter data in couchbase View

When i write view in couchbase to return whole doc it also return _sync":{} data, is there any way to remove this data from response. here is my view function:- function map(doc, meta) { if (doc.type == 'user' && doc.user_id) { …
rash
  • 91
  • 7
1
vote
1 answer

is Couchbase Lite update views(indexes) automatically when we insert new docs ? or we need to do it manually?

i started researching on mobile embed databases and i came across couchbase , awesome.still i didn't understand some of the concepts , one of them is how to work with views and queries. they are saying that views are indexes. but they never…
1
vote
1 answer

Couchbase: 1 MB size exceeded for value in index view

I see that value in view has exceeded 1 MB size (it is 1.7 MB) and thereby not getting emitted in views. I have tried to change values of max_kv_size_per_doc in default.ini (then restarted couchbase) but still value is not getting emitted. Could…
I Am
  • 33
  • 1
  • 4
1
vote
2 answers

quering couchbase views by secondary index and ordering results

I have documents in my bucket: { type: "post", author: "1", subject: "s1", timestamp: 11} { type: "post", author: "1", subject: "s2", timestamp: 12} { type: "post", author: "2", subject: "s3", timestamp: 9 } { type: "post", author: "3", subject:…
Łukasz
  • 623
  • 5
  • 12
1
vote
2 answers

Couchbase full-text search and compound keys

I have the following data in Couchbase: Document 06001: { "type": "box", "name": "lxpag", "number": "06001", "materials": [ { "type": "material", "number": "070006", "name": "hosepipe" }, { "type":…
Bastian
  • 4,638
  • 6
  • 36
  • 55
1
vote
0 answers

How to create Primary Index for password protected buckets in Couchbase

I have a bucket name user-account with password 'user' and I am trying to create Primary Index on this bucket CREATE PRIMARY INDEX ON `user-account` but its giving { "requestID": "83e90d2d-18dc-4eb7-af34-7d689d962c8a", "signature":…
Ayush Mishra
  • 567
  • 1
  • 7
  • 19
1
vote
0 answers

Couchbase Java SDK cannot get and delete documents

I don't get why this doesn't delete all the documents in the view. I'm using Couchbase Java SDK 2.1.3 with Couchbase 3.0.3. public class Main { public static void main(String[] args) { // Create a cluster reference …
sscarduzio
  • 5,938
  • 5
  • 42
  • 54
1
vote
1 answer

Creating Couchbase views in code: First query returns 0 rows, index builds in background

I am creating a view in code using the Couchbase Java API 2.1.2 like this: DefaultView view = DefaultView.create(viewName, jsMapFunctionAsString); List views = new ArrayList<>(); views.add(view); DesignDocument doc =…
Sebastian
  • 5,177
  • 4
  • 30
  • 47
1
vote
0 answers

Couchbase View Empty

I actually use couchbase with the java client, but when i query my view, the result is empty. But when i check the number of rows returned, it returns the good number of rows in the database : ViewResult result = bucket.query(ViewQuery.from("logs",…
Arthe
  • 53
  • 3
1
vote
1 answer

Couchbase reduce multiple values

I am building a view in Couchbase 3.0.1 and would like to reduce multiple values from a map, but I am not sure the right approach. In the case of an order object, the problem I am trying to solve is that I would like to reduce multiple values from…
ski_junkie
  • 617
  • 1
  • 7
  • 14