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
0
votes
1 answer

How to retrieve data by property in Couchbase Lite?

My documents have the property docType that separated them based on the purpose of each type, in the specific case template or audit. However, when I do the…
Tarcisiofl
  • 151
  • 4
  • 12
0
votes
1 answer

CouchbaseLite 1.3.0 view querying id of doctype

I am using couchbase lite 1.3.0 for an ios app. I am saving the model objects as docs in the db. However I am changing the 'doctype' dynamically while saving. Upon querying with 'docType' id , the cbl view emits wrong/unmatching 'docType'. Couldn't…
0
votes
1 answer

Android - CouchBase lite - com.couchbase.lite.View - database.getExistingView

I'm working with an android application using couchbase lite. I have a view byDate (with Mapper) which is created at the first launch of my application. But when I close and re-launch my application. database.getExistingView("byDate") return an…
Anh-Tuan Mai
  • 1,129
  • 19
  • 36
0
votes
1 answer

couchbase Reduce gives not wanted result

I have a map function that returns a result like this…
Monta
  • 1,136
  • 1
  • 12
  • 28
0
votes
1 answer

Custom map reduce functions in couchbase

i want to use Couchbase Map Reduce Functionality. My input is as follows: { "domain": "cnn.com", "country": "USA", "value": 1 } Each document represent a single access to a domain from a specific source country, I want to be able to…
Shahar
  • 13
  • 5
0
votes
1 answer

couchbase server not return id within record using c# code

when we get records from couchbase server using select query not get id of each record my code below . what i am missing var clientConfiguration = new ClientConfiguration(); clientConfiguration.Servers = new List { new…
0
votes
1 answer

dev and prod views give different results

I try to map and reduce datas with a couchbase view. While in dev, everything is ok. The value returned by the reduce function is the json formated doc i'm waiting. But when I publish the view in prod, I only got null values (keys seems to be ok :…
Jice
  • 191
  • 4
  • 16
0
votes
1 answer

No row returned when querying a couchbase view with python

I'm trying to query a view from the python sdk but I have no row returned. My map function is : function (doc, meta) { if (doc.EXENUM_A !== null) { if (doc.PRS != null) { emit(doc.EXENUM_A, doc.PRS); } } } The reduce one is…
Jice
  • 191
  • 4
  • 16
0
votes
1 answer

parsing JSON object to a list of a model from couchbase view

I am trying to make a mapreduce view in couchbase like so. Right now my view code in couchbase server looks like this, function(doc, meta) { emit(doc.content,null); } where I am emitting the content of a document. so when I iterate in (var rows…
0
votes
1 answer

Get total_rows from couchbase ruby library

When having a look to my couchbase view using the web api I got this result: { "total_rows": 18279385, "rows": [] } But I'm using the ruby couchbase gem like follows require 'couchbase' c = Couchbase.connect(...) sources =…
PascalTurbo
  • 2,189
  • 3
  • 24
  • 41
0
votes
1 answer

How to set input variable as key in json while creating view in couchBase

I am trying to create user specific views on couchBase from Node.js. Here is the code I have app.post("/todo/:id", function(req, res){ console.log("hey" + req.body.userId) baseview.setDesign('design_users', { "$req.body.userId": { …
user1384205
  • 1,231
  • 3
  • 20
  • 39
0
votes
1 answer

PHP pagination with Couchbase gets very slow at high page numbers

I've build a PHP based webapp with pagination. I've made both a Couchbase and a Postgres version. I had to abandon N1QL because it had terrible performance (maybe I'll make another question for that). So I migrated the project from N1QL to views. I…
Mattia_98
  • 133
  • 1
  • 7
0
votes
1 answer

Couchbase compound key with range filtering & ordering and filtering by second key

I have documents, that look like { ... date: '2013-05-25T04:06:20.277Z', user: 'user1' ... } I would need to find documents that have a date within a given range, and a given user. I also need to sort by date. I have tried…
Mico
  • 1,978
  • 2
  • 13
  • 17
0
votes
1 answer

Couchbase Get() followed by atomic Increment()

I have a program that does the following : Check if the key is present in couchbase using Get() If its present then don't do anything, return a false to the calling application. if the key is not present, then increment it with a value of 1. So…
skywalker2909
  • 1,636
  • 2
  • 31
  • 46
0
votes
1 answer

Couchbase View equivalent of Select count(doc.id) from doc where doc.productId in (select productId from doc where doc.lastupdated between x and y)

I'm trying to count the number of 'comments' related to a product in a couchbase bucket. That part is easy for a "full" set of data. It's just a simple map / reduce. Things get tricky when i want limit it to only products that have had changes…
MarcusP
  • 15
  • 3