Couchbase View - Sort by Value

Hi,

I had a query on sorting the results of a Couchbase View by Value instead of Key.
Couchbase Version - 4.1.0

As per various sites online, it was mentioned that we cannot sort the results by value.
I have the following queries

1> Is there a way to use custom logic in the reduce function to sort the Couchbase View by value, without affecting performance?

2> Is the facility for sorting Couchbase View by value going to be made available in any upcoming future versions? If so, which version and by when?

Note: I needed to sort by value because i then wanted to retrieve only a partial list of results (say top 10 records) to avoid processing at client end.

Thanks,
Sheldon

1 Like

You want to change your map() function to emit the field you want to sort on first, then followed by the other field(s) you care about.

1 Like