Hello! After some discussion, sorting support for zope.index was added. It's now in zope.index 3.5.0. So, the next step is to add sorting/limiting/reversing to zope.app.catalog. I made a "nadako-sorting" branch of zope.app.catalog. It modifies the ``searchResults`` method of the catalog so it makes use of special keyword arguments, passed to it (i believe that's just like zope 2 catalog works). The names are: * _sort_index - the name of index to sort with * _reverse - reverse results * _limit - limit result set I added an underscore to the names to mark them as something special, not just index names and to avoid conflicting with index names that applications might use. I think there's no application on earth that has indexes with the names above, so that's not a problem. If _sort_index is not specified, catalog just uses list mechanisms to limit/reverse results. I don't think that makes any sense though. If _sort_index is specified, all sorting, reversing and limiting functionality is done by the ``sort`` method of specified index. That index should provide the new IIndexSort interface, defined by zope.index. I would like to merge that code to zope.app.catalog trunk and make a new feature release, containing this functionality. So I'd like community to review these changes and comment/object it. Thanks! -- WBR, Dan Korostelev
Dan Korostelev wrote:
If _sort_index is not specified, catalog just uses list mechanisms to limit/reverse results. I don't think that makes any sense though. If _sort_index is specified, all sorting, reversing and limiting functionality is done by the ``sort`` method of specified index. That index should provide the new IIndexSort interface, defined by zope.index.
Hi Dan, Note that there's a slight optimization that could be added to z.a.catalog that could help in a very limited case. If the _sort_index is also a search index in the query, if you run an intersection against that index last (e.g. via "weightedIntersection"), the results will already be sorted by value and the sort method of the index needn't be run. At least I think this is true. - C
participants (2)
-
Chris McDonough -
Dan Korostelev