sics
sics

Reputation: 1318

Couchbase: Synchronizing views with a bucket

I've got a question for you couchbase pros: Is it possible to synchronize a subset of documents (eg. the documents within a view) with an other bucket?

So that the other bucket documents are always a direct subset of the "master" bucket? if so, isn't that to much expensive in terms of perfomance? or does couchbase have any functionality to only create deeplinks to the documents instead of copying it?

Alternatively: is it possible to write views on views?

Thank you in advance!

--- EDIT ----

Let's say I want to have two sets (buckets) of documents S1 and S2. S2 is a subset of S1. Each set contains the same views V1, V2 and V3 since I want to be able to query any of them with the same logic/interface. In my case set S2 is build per user/company/store/whatever, in production there should be like 1000ish subsets S2 - to stay abstract let's call them S2a S2b and S2c.

The selection of documents which to be contained in any subset is done by a filtering instance (for example a view). Let's call these filtering instances F1 for filtering S1 to S2 hence F1a, F1b and F1c.

So with my actual knowledge of couchbase this results in the following design/view architecture: I've got the three "base" views to display V1,V2 and V3, and to realize S2a, S2b and S2c I must create the design views S2aV1, S2aV2, S2aV3, S2bV1, S2bV2, etc. (9 Views).

One could say "Well choose your keys wisely and you can avoid the sub views" but in my opinion this isn't that easy because of the following circumstances: In worst case the filter parameters change every minute and contain many WHERE IN constraints which could (at my actual point of view) not be handled efficiently querying k/v lists.

This leads to the following thoughts and the question I initially asked. If I use the same views in any subset (defined by a filter) shouldn't it be possible to build up an entity which helps me handling complex filtering? For example a function which is called during runtime while generating the view output? This could look like /design/view?filter=F1 or something like that.

Or do you have any other ideas to solve this problem? Or should I use SQL since it's more capable of handling frequently changing filters?

Upvotes: 0

Views: 539

Answers (3)

J Chris
J Chris

Reputation: 11

We are working on Elastic Search integration. Maybe better for your use case

Upvotes: 1

scalabl3
scalabl3

Reputation: 1273

Generally speaking for most models you don't really need to have bucket "subsets", is there a particular reason you are trying to do this and why you would want that data broken out? You can also query your views, or instead of a view on a view, you can just make a separate view that maps/filters further based on your needs (i.e. does the same job as a view on a view).

Upvotes: 2

J Chris A
J Chris A

Reputation: 2168

I think what you want to do is write a view on your original bucket, and then copy the key/values from that view, to be documents in a new bucket.

It shouldn't be hard to write an automated framework for managing this so that you can keep the derived data up to date in near real time.

Upvotes: 0

Related Questions