case-independant catalog sorting
Does anyone know how to get a sort on a (zcatalog) FieldIndex to be case-independent (case-folding)?
Write a PythonScript that returns the content to be indexed in a normalized form and place it somewhere in the top of your site. -aj --On Dienstag, 11. Mai 2004 18:20 Uhr -0400 Marc Lindahl <marc@bowery.com> wrote:
Does anyone know how to get a sort on a (zcatalog) FieldIndex to be case-independent (case-folding)?
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
you mean, re-sort the set of results returned by the catalog? On Wednesday, May 12, 2004, at 12:51 AM, Andreas Jung wrote:
Write a PythonScript that returns the content to be indexed in a normalized form and place it somewhere in the top of your site.
-aj
--On Dienstag, 11. Mai 2004 18:20 Uhr -0400 Marc Lindahl <marc@bowery.com> wrote:
Does anyone know how to get a sort on a (zcatalog) FieldIndex to be case-independent (case-folding)?
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
No, if you want to index an attribute 'foobar' then go and create a pythonscrip in the zope root 'foobar_index': return context.foobar.lower() The create a FieldIndex 'foobar_index'. This call the pythonscript for every object and the pythonscript will return the attribute in lowercase... -aj --On Mittwoch, 12. Mai 2004 2:54 Uhr -0400 Marc Lindahl <marc@bowery.com> wrote:
you mean, re-sort the set of results returned by the catalog?
On Wednesday, May 12, 2004, at 12:51 AM, Andreas Jung wrote:
Write a PythonScript that returns the content to be indexed in a normalized form and place it somewhere in the top of your site.
-aj
--On Dienstag, 11. Mai 2004 18:20 Uhr -0400 Marc Lindahl <marc@bowery.com> wrote:
Does anyone know how to get a sort on a (zcatalog) FieldIndex to be case-independent (case-folding)?
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Oh I see. I was hoping that you could pass instructions via a record, like you can tell DateTime indices to sort in different ways.... On Wednesday, May 12, 2004, at 02:57 AM, Andreas Jung wrote:
No,
if you want to index an attribute 'foobar' then go and create a pythonscrip in the zope root 'foobar_index':
return context.foobar.lower()
The create a FieldIndex 'foobar_index'. This call the pythonscript for every object and the pythonscript will return the attribute in lowercase...
-aj
--On Mittwoch, 12. Mai 2004 2:54 Uhr -0400 Marc Lindahl <marc@bowery.com> wrote:
you mean, re-sort the set of results returned by the catalog?
On Wednesday, May 12, 2004, at 12:51 AM, Andreas Jung wrote:
Write a PythonScript that returns the content to be indexed in a normalized form and place it somewhere in the top of your site.
-aj
--On Dienstag, 11. Mai 2004 18:20 Uhr -0400 Marc Lindahl <marc@bowery.com> wrote:
Does anyone know how to get a sort on a (zcatalog) FieldIndex to be case-independent (case-folding)?
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
if you want the index to remain casesensitive then you should use sequence.sort() to sort the results. You can pass your own comparision method to sequence.sort() ... read the docs for details. -aj --On Mittwoch, 12. Mai 2004 2:54 Uhr -0400 Marc Lindahl <marc@bowery.com> wrote:
you mean, re-sort the set of results returned by the catalog?
On Wednesday, May 12, 2004, at 12:51 AM, Andreas Jung wrote:
Write a PythonScript that returns the content to be indexed in a normalized form and place it somewhere in the top of your site.
-aj
--On Dienstag, 11. Mai 2004 18:20 Uhr -0400 Marc Lindahl <marc@bowery.com> wrote:
Does anyone know how to get a sort on a (zcatalog) FieldIndex to be case-independent (case-folding)?
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
I was trying to let Catalog do the sorting, and avoid that (or - would it be faster to get unsorted results from the catalog and sort the results using sequence.sort?) On Wednesday, May 12, 2004, at 02:59 AM, Andreas Jung wrote:
if you want the index to remain casesensitive then you should use sequence.sort() to sort the results. You can pass your own comparision method to sequence.sort() ... read the docs for details.
-aj
--On Mittwoch, 12. Mai 2004 2:54 Uhr -0400 Marc Lindahl <marc@bowery.com> wrote:
you mean, re-sort the set of results returned by the catalog?
On Wednesday, May 12, 2004, at 12:51 AM, Andreas Jung wrote:
Write a PythonScript that returns the content to be indexed in a normalized form and place it somewhere in the top of your site.
-aj
--On Dienstag, 11. Mai 2004 18:20 Uhr -0400 Marc Lindahl <marc@bowery.com> wrote:
Does anyone know how to get a sort on a (zcatalog) FieldIndex to be case-independent (case-folding)?
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Marc Lindahl wrote at 2004-5-12 12:35 -0400:
I was trying to let Catalog do the sorting, and avoid that (or - would it be faster to get unsorted results from the catalog and sort the results using sequence.sort?)
Usually, sorting via "sequence.sort" is much slower than sorting via an index. On the other hand, "sequence.sort" is much more flexible... -- Dieter
participants (3)
-
Andreas Jung -
Dieter Maurer -
Marc Lindahl