Proposed New sort API

David Bremner david at
Sat Oct 20 04:43:54 PDT 2018

William Casarin <jb55 at> writes:

> David Bremner <david at> writes:
>> I started looking at William's sorting patches [1], but the
>> proliferation of sorting options bugged me a bit. I decided to sketch
>> out a new more flexible API.
>> In the new API, there is is a sort "key", currently mapped one-to-one
>> to value slots, but potentially could do more sophisticated things
>> like making keys up dynamically (e.g. preprocessing subjects).
>> The second parameter is a sort "type". Currently this is just
>> ascending or descending, but other potential options include
>> sort_by_relevance_then_value
> Another thought I had that I wanted to throw out there for
> consideration. It would be nice to be able to sort by "popular" threads,
> aka sort by the number of messages in each thread. Not sure if this is
> an easy thing to do at the query level?

I don't see how to manage it as a xapian query. In the current database
schema xapian doesn't really know about threads, except that messages
know what thread they belong to.

More information about the notmuch mailing list