ZCTextIndex and ZCatalog conundrum
Hi, Say I have a ZCatalog with a ZCTextIndex called 'SearchableText' and a DateIndex called dateofpublication. I do a search like: results = MyCatalog(SearchableText = search_expression, dateofpublication = search_expression2) How would I get those results sorted by the relevence returned by the ZCTextIndex? cheers, Chris
First, you can not use the sort_on parameter since TextIndexes do not provide the necessary keyForDocument() method. This method does not make sense for Textindexes because it would return the content instead of the ranking which is bound to the query and its resultset. I think the only way is to call the indexes directly and munge the results from both indexes. ZCTextIndex has a query() that returns a mapping docid -> score. With these informations it should not be too hard to solve your problem. -aj --On Dienstag, 29. April 2003 14:19 Uhr +0100 Chris Withers <chrisw@nipltd.com> wrote:
Hi,
Say I have a ZCatalog with a ZCTextIndex called 'SearchableText' and a DateIndex called dateofpublication.
I do a search like:
results = MyCatalog(SearchableText = search_expression, dateofpublication = search_expression2)
How would I get those results sorted by the relevence returned by the ZCTextIndex?
cheers,
Chris
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Andreas Jung wrote:
First, you can not use the sort_on parameter since TextIndexes do not provide the necessary keyForDocument() method.
Indeed. Is there any way keyForDocument could be implemented to do what's required?
I think the only way is to call the indexes directly and munge the results from both indexes. ZCTextIndex has a query() that returns a mapping docid -> score. With these informations it should not be too hard to solve your problem.
Hmmm... it just strikes me that this really sucks. sort_on seems the way I'd expect it to work as a user. How do we make that work? cheers, Chris
--On Donnerstag, 1. Mai 2003 10:39 Uhr +0100 Chris Withers <chrisw@nipltd.com> wrote:
Andreas Jung wrote:
First, you can not use the sort_on parameter since TextIndexes do not provide the necessary keyForDocument() method.
Indeed. Is there any way keyForDocument could be implemented to do what's required?
No, the ranking value is bound to the result set and not to the index. Since the ZCatalog asks the index for key and not the result set. I agree that it would be nice to have a better sorting functionality based on the ranking informations of result sets but a change might break the API for indexes. -aj
participants (2)
-
Andreas Jung -
Chris Withers