couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Davis" <paul.joseph.da...@gmail.com>
Subject Re: User defined sort directions.
Date Mon, 10 Nov 2008 14:07:17 GMT
On Mon, Nov 10, 2008 at 6:44 AM, tasman <tasman.main@gmail.com> wrote:
>
> On Nov 9, 2008, at 11:54 PM, Paul Davis wrote:
>
>> Hey guys,
>>
>> Just created a ticket and added a patch for user definable view sort
>> directions.
>>
>> https://issues.apache.org/jira/browse/COUCHDB-158
>>
>> Basically, this allows you to sort array keys based on the array
>> position. Its only ascending vs. descending.
>>
>> An example design document would be something like:
>>
>> {
>>  "_id": "_design/foo",
>>  "_rev": "872300123",
>>  "views": {
>>    "bar": {
>>      "map": "function(doc) {emit([doc.val1, doc.val2], null);}",
>>      "sort": [false, true]
>>    }
>>  }
>> }
>>
>> That'd sort descending on the doc.val1, and ascending on val2.
>>
>> When the sort array is shorter than the emitted view key, all values
>> are assumed to be true.
>>
>> Anyone have thoughts?
>
>  May be it would be better to pass sort oder list into view request?
>

In an ideal world, but that wouldn't work in couch's case. The sort
needs to be known when creating the btree. Otherwise we'd have to
resort an entire view on every request. Or store things in multiple
btrees and then do joins. Neither of these things is easy.

Paul

>>
>> Paul
>
>

Mime
View raw message