I'm using couchbase 3.0.1 Community Edition (build-1444). I have documents with a date and an array of tags:
{
// ...
date_start: '2015-09-25',
tags: ['tag1', 'tag2'],
// ...
}
I created a view to match these documents by tags:
function (doc, meta) {
// some tests to be sure the doc is alright
// ...
for (var i = 0, i < doc.tags.length; i += 1) {
emit(doc.tags[i], null);
}
}
When creating a query to fetch tags by keys, everything is ok. But now, what is the best way to sort this by date_start descendant?
I saw in the doc (http://docs.couchbase.com/admin/admin/Views/views-querying.html) that:
When using this query option [keys], the output results are not sorted by key. This is because key sorting of these values would require collating and sorting all the rows before returning the requested information.
What if I still would like to sort?
----- EDIT -----
I'm using a limit to fetch only the last five documents with these tags. And that's the point: this limit should retrieve documents by tags but with the date ordered.
Thanks