ZCatalog: sorting on multiple indexes
Hi all, this appears to be an old question, but I have not found any reply on the mailing list archives. Is there any trick to sort the results from ZCatalog on two or more indexes ? TIA, --peppo
Can't currently be done at query time. However, you could populate a sort index with a combo of the values you want to sort on, such as this python script code: return context.lastname + context.firstname Put this in a Python script named LastFirst and add a matching field index and reindex it. Now use that as your sort index and you'll sort on multiple values. If the values aren't addable, then you can also just index a tuple of arbitrary length like: return (context.attr1, context.attr2, context.attr3) I have recently been working on the ZCatalog sorting code and it is possible to add this capability for Zope 2.7. How do people feel about this? Would many of you use it? I suppose one use would be grouping on reports. Zope 2.7 will contain many different sorting algorithms, it is likely that sorting on multiple keys will limit you to just a few possible algorithms. So the above technique would still be useful for best performance, however it is much less flexible. -Casey On Wednesday 11 December 2002 09:04 am, Giuseppe Bonelli wrote:
Hi all,
this appears to be an old question, but I have not found any reply on the mailing list archives.
Is there any trick to sort the results from ZCatalog on two or more indexes ?
TIA,
--peppo
The sequence.sort() method supports multidimensional sorting. CHeck the docs for details. -aj --On Mittwoch, 11. Dezember 2002 15:04 +0100 Giuseppe Bonelli <giuseppe.bonelli@tiscali.it> wrote:
Hi all,
this appears to be an old question, but I have not found any reply on the mailing list archives.
Is there any trick to sort the results from ZCatalog on two or more indexes ?
TIA,
--peppo
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
--------------------------------------------------------------------- - Andreas Jung http://www.andreas-jung.com - - EMail: andreas at andreas-jung.com - - "Life is too short to (re)write parsers" - ---------------------------------------------------------------------
Andreas Jung wrote:
The sequence.sort() method supports multidimensional sorting. CHeck the docs for details.
Yeah, but that's not gonna be nearly as efficient as actually using the catalog indexes to sort. I'm going to offer up sacrifices to the god of catalog, otherwise known as Casey ;-) cheers, Chris
participants (4)
-
Andreas Jung -
Casey Duncan -
Chris Withers -
Giuseppe Bonelli