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
2
votes
2 answers

Couchbase Indexing Views too frequently

I am accessing Couchbase views frequently (every minute - run through the thread) with Java 2.1 SDK with Stale parameter as FALSE. Sometime I could see the indexing got stuck for long time. Should I remove the stale Parameter from code or reduce the…
Sivailango
  • 544
  • 1
  • 6
  • 15
2
votes
0 answers

Node.js to query Couchbase view

I am new to using Couchbase but based on the documentation it seems that Couchbase is a good fit for my use case to store user data as documents. I have created a view on Couchbase which I am able to run and see the results in the dashboard. However…
user1384205
  • 1,231
  • 3
  • 20
  • 39
2
votes
1 answer

Couchbase N1QL query against existing view

Im new to Couchbase and I'm wondering if it is possible to perform a N1QL query based on an existing View. I'm curious if something like this would work in Couchbase: Select * From `MY_VIEW_INSTEAD_OF_BUCKET` where id = 12 From what I've…
Marquis Blount
  • 7,585
  • 8
  • 43
  • 67
2
votes
1 answer

Is Couchbase Lite meant for Querying Data?

We are looking at implementing Couchbase for an iPad App built with Xamarin.IOS. This is the first time we are digging into Couchbase and wanted to make sure that our use case is something that is doable with Couchbase. Our primary use case is to be…
Yashvit
  • 2,337
  • 3
  • 25
  • 32
2
votes
2 answers

Can Sync gateway views be pulled/replicated on client side?

I have this use case, where I have created server side views on sync gateway based on a rolling time window of 10 days. Is there a way to directly pull those on my device side? When I look at the documentation, I see that there's no way these can…
Sagar
  • 229
  • 4
  • 14
2
votes
1 answer

Response custom error when key not satisfies the exact value in couchbase view

I have a document like - { "fullUserName": "xxyz", "userFirstName": "xx", "userLastName": "xx", "primaryRole": "xy", "actualRole": "rrr", "userId": "abcd1234", "password":"c28f5c7cb675d41c7763ab0c42d", "type":"login", "channels":"*" } and…
Samir
  • 6,658
  • 3
  • 16
  • 27
2
votes
1 answer

Querying Couchbase view by passing parameter

I have Couchbase notification documents stored in below format: { "_id":"notification::5403cb1a6c965dcfe9", "alert":"test data", "body":{ "created_by":"user_54986e326694f10e511cf", "description":" reported ", }, …
rash111
  • 1,307
  • 4
  • 19
  • 35
2
votes
1 answer

Couchbase gives badarg error

I Created simple couchbase spatial view to get list of report, but it gives {error: "error", reason: "badarg"} error. Here is my view:- function (doc, meta) { if (doc.type == "report" && doc.location && doc.location.type &&…
rash111
  • 1,307
  • 4
  • 19
  • 35
2
votes
1 answer

couchbase substr function for results

I am trying to display the results the substring value of one of my properties. My data has records with a field called serialNumber, and I have a view like this that returns those records that have "XY" in the field: function (doc, meta) { if…
2
votes
1 answer

What is the rule to assign memory quota in Couchbase?

I have 4 buckets with 11MB, 111MB, 1.1GB and 2.2GB sizes and each of these bucket contains many views in different document design in standalone mode. How much memory should I assign in these buckets? is there any rule? Any theory behind it?
Prakash Thapa
  • 1,285
  • 14
  • 27
2
votes
4 answers

Using N1QL with document keys

I'm fairly new to couchbase and have tried to find the answer to a particular query I'm trying to create with not much success so far. I've debated between using a view or N1QL for this particular case and settled with N1QL but haven't managed to…
Spacemonkey
  • 211
  • 3
  • 10
2
votes
2 answers

querying couchbase with spring-data-couchbase, using multiple columns

I am using couchbase3 with spring-data-couchbase, and want to query data using spring data repository with multiple columns. public interface UserAccountRepository extends CrudRepository { public UserAccount findByEmail(Query…
2
votes
1 answer

How to write a view in couchbase for this sql statement

Let's say I have the following documents Document 1 { companyId: "1", salesDate: "1425254400000" //this is UTC time as a long } Document 2 { companyId: "1", salesDate: "1425340800000" //this is UTC time as a long } Document 3 { companyId:…
Andrew
  • 577
  • 7
  • 20
2
votes
1 answer

Add name attribute to what gets emitted from a view in couchbase

I have a really simple emit statement in a view. emit([doc.salesDate, doc.companyId], doc.grossSales); Is there any way I can make the JSON object it returns show up like this { "grossSales" : "100" } instead of { 0: "100" } EDIT: I'm…
Andrew
  • 577
  • 7
  • 20
2
votes
1 answer

Get counter documents from couchbase view

We using Couchbase's increment function to store some counters on variable keys with constant prefix SomePrefix_. We define view that get all documents which keys start with SomePrefix_: function (doc, meta) { if (meta.id.indexOf("SomePrefix_")…
ilyabreev
  • 628
  • 6
  • 20
1 2
3
13 14