Migration to Couchbase and design question


#1

Hello,
We are thinking about migration to Couchbase. We thought about mongodb to add to redis and elasticsearch but couchbase seems better tool for what we want. Most of the data i know how to migrate and how to model it but… Data modeling choice is not so trivial if we take some things into consideration. So there are 2 obvious ways how to model JSON documents if you have lists but…
What about that kind of use case:

We have a list that we present to our users. Structure of every document in the list is something like this:

{
String1 : “some text”,
String2: “some text”,
String3: “some more text”,
String4Categories(can be represented as ints too): enumerable(around 10 choices),
Timestamp: someTimestamp,
int1: someInt,
int2: someInt2,
int3: someInt3,
}

All the strings, one int and timestamp do not change at all, but two of INTs change (Incrementing/decrementing) A LOT.

Users are getting 100 results from this list sorted by timestamp, but they can make a new request and sort it ascending/descending by any of the atributes of this documents (string1/timestamp/int2 etc.). Or they can group results by categories so they will only see all the results from category1 or from category1 combined with category2 etc.
Collection of this documents for now is around ~100k, it’s not growing very fast, less than 200 a day.

Structure of list is similar to for example list of products on let’s say ebay. But in this case besides sorting, choosing categories we have couple of write heavy ints and we need to show data almost real time (those ints can be a little out of date).

What is the best way to implement this in couchbase if performance (thgrouthput and latency) is a concern ?


#2

Hmm…So can anyone help me please ? I don’t want exact solution, just an hint/idea how to implement it for best performance (throughput and latency) considering conditions i gave. So how to structure this list… make it in one document in array… or only array of id’s of other documents… how efficiently construct views to that structure… etc.
I’ve asked this question on SO too, but no answers yet. I greatly appreciate any help that anyone could give.


#3

Hi,

Without knowing all of the constraints affecting your data model it sounds like something that could be done with views. Depending on the application SLA and consistency tolerance the ability to query the view, sort ascending/descending, grouping using a start_key/stop_key to assist in passing parameters in should work well if the data is modeled for rapid retrieval.

The next version of the product, (developer preview is being released in April) contains a rich query api and full in memory indexing using N1QL (SQL For Documents) that suits this type of use case.

Thanks