Hi all, I've setup a site search using ZCatalog and ZCTextIndexs that's happily doing what I want, but I'd like to take a stage further. Is there a way using the ZCatalog Brain objects returned by the ZCatalog search to get the text that actually caused the match? I'm trying to end up with a preview of the area of the content that caused the match, or is a different approach needed? The only way I can think of doing this at the moment is to get the actual content object via the ZCatalog brain object and then re-run a regex search on the content, pulling out the text around any match. This just seems the wrong way forward is there a better way? Thanks for any pointers, I'm still very much in the newbie class at present. Brian http://www.bbc.co.uk/ This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated. If you have received it in error, please delete it from your system. Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately. Please note that the BBC monitors e-mails sent or received. Further communication will signify your consent to this.
--On Donnerstag, 20. Januar 2005 10:43 Uhr +0000 Brian Ling <brian.ling@bbc.co.uk> wrote:
I've setup a site search using ZCatalog and ZCTextIndexs that's happily doing what I want, but I'd like to take a stage further. Is there a way using the ZCatalog Brain objects returned by the ZCatalog search to get the text that actually caused the match? I'm trying to end up with a preview of the area of the content that caused the match, or is a different approach needed?
A Zcatalog search returns the objects (or better their proxies) that fullfill the query. You have to grab the content from the object and perform post-query operations on your own. There is no direct solution where Zope would help you out-of-the-box. -aj
Zcatalog searches<snip> From: Brian Ling Hi all, I've setup a site search using ZCatalog and ZCTextIndexs that's happily doing what I want, but I'd like to take a stage further. Is there a way using the ZCatalog Brain objects returned by the ZCatalog search to get the text that actually caused the match? I'm trying to end up with a preview of the area of the content that caused the match, or is a different approach needed? The only way I can think of doing this at the moment is to get the actual content object via the ZCatalog brain object and then re-run a regex search on the content, pulling out the text around any match. This just seems the wrong way forward is there a better way? </snip> You have to grab the text from the search result objects and do your own matching (regex works). Be careful to match for the same terms used in the index (ie. if you have done any kind of stemming you need to take this into consideration). This is exactly what we have done for one of our sites (shopwiser.com - you can see how it works by entering a search term and seeing your search term highlighted in the results). Jonathan
Jonathan Hobbs wrote:
You have to grab the text from the search result objects and do your own matching (regex works). Be careful to match for the same terms used in the index (ie. if you have done any kind of stemming you need to take this into consideration). This is exactly what we have done for one of our sites (shopwiser.com - you can see how it works by entering a search term and seeing your search term highlighted in the results).
to get the same query terms the catalog matched you'd probably best to match the terms against the lexicon of the zctextindex (after all that's what the catalog query machinery does as well). The lexicon may be queried separately. The list of terms may also be useful for user feedback Rik Hoekstra
participants (4)
-
Andreas Jung -
Brian Ling -
Jonathan Hobbs -
Rik Hoekstra