Here is a common use case that I haven't managed to find a solution for:
Consider this document type:
{ "fromDate" : "2014-03-10T00:00:00.000Z", "thruDate" :
"2014-03-11T00:00:00.000Z" }
There are two main types of queries I want for this data.
1. Given a "current" time stamp, retrieve all documents where "fromDate"
is less than or equal to "current", and where "thruDate" is either null or
is not less than "current".
Essentially, documents are valid for this view where our "current"
timestamp falls within the range implied by [fromDate, thruDate).
2. Similar to query #1, but "distinct", meaning that no more than one
record may be "valid" for any given "current" timestamp.
Attempts to implement this design in Couchbase have been elusive. I've
tried different approaches, such as numeric date formats and using the
dateToArray function in various ways, but the underlying issue is that
there isn't a good way to construct an "OR" query based on document fields.
Finding documents based on either the "from" or "thru" timestamps is easy,
but bounding documents where the query is "between" the from and thru
timestamps is not.
It appears that in order to accomplish this use case, the application must
be willing to retrieve large sets of keys and then evaluate them by value,
sorting the view by value and then evaluating the dates, eliminating rows.
That is a poor solution when the result size becomes large.
I would be encouraged by any suggestions. I'm using Couchbase Server 2.2
and the Java Client API, and am reasonably comfortable with Design Document
/ View construction.
Kind regards,
James
--
You received this message because you are subscribed to the Google Groups
"Couchbase" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.