Finding unique objects in a ZCatalog returned list
Hello, I'm doing quick search using several indexes in a ZCatalog as below <dtml-in expr="Catalog(title=query) + Catalog(category=query) + Catalog(description=query) + Catalog(product=query) + Catalog(keywords=query)"> This works really well. However, if my query string is found in more than one index I get the same object returned more than once. How do I sort the list of objects returned and more importantly remove duplicate objects? Thanks for any help. Mike Dr Mike Groves Software Strategist Polymer Laboratories Ltd, Unit 8, The Mynd Industrial Estate Church Stretton, Shropshire, SY6 6EA, U.K. Tel: +44 1694 724420 Fax: +44 1694 724434 Website:http://www.polymerlabs.com ---- The Information in this communication is confidential and may be privileged and should be treated by the recipient accordingly. If you are not the intended recipient please notify me immediately. You should not copy it, or use it for any purpose nor disclose its contents to any other person. Opinions, conclusions and other information expressed in this message are not given or endorsed by Polymer Laboratories Ltd. unless otherwise indicated by an authorised representative independent of this message. Any quotations, offers for sale or negotiations on behalf of the company contained in this Email are Subject to Contract and require alternative confirmation.
On Thu, 21 Jun 2001, Mike Groves wrote:
I'm doing quick search using several indexes in a ZCatalog as below
<dtml-in expr="Catalog(title=query) + Catalog(category=query) + Catalog(description=query) + Catalog(product=query) + Catalog(keywords=query)">
This works really well. However, if my query string is found in more than one index I get the same object returned more than once.
How do I sort the list of objects returned and more importantly remove duplicate objects?
Put all results in a dictionary, mapping URL to object. Do it in Python Script, of course. Oleg. ---- Oleg Broytmann http://www.zope.org/Members/phd/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.
On Thu, 21 Jun 2001, Oleg Broytmann wrote:
On Thu, 21 Jun 2001, Mike Groves wrote:
I'm doing quick search using several indexes in a ZCatalog as below
<dtml-in expr="Catalog(title=query) + Catalog(category=query) + Catalog(description=query) + Catalog(product=query) + Catalog(keywords=query)">
This works really well. However, if my query string is found in more than one index I get the same object returned more than once.
How do I sort the list of objects returned and more importantly remove duplicate objects?
Put all results in a dictionary, mapping URL to object. Do it in Python Script, of course.
Oops, forgot to say, that even this does not guarantee uniquness. Consider these URLs: http://my.server/Folder http://my.server/Folder/ http://my.server/Folder/index_html 3 different URLs point to the same object. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.
Mike Groves wrote:
Hello,
I'm doing quick search using several indexes in a ZCatalog as below
<dtml-in expr="Catalog(title=query) + Catalog(category=query) + Catalog(description=query) + Catalog(product=query) + Catalog(keywords=query)">
This works really well. However, if my query string is found in more than one index I get the same object returned more than once.
How do I sort the list of objects returned and more importantly remove duplicate objects?
Thanks for any help.
Another approach would be to create a Py script as an instance method of the ZClass that concatenates all of these properties values and returns the result. Something like: return container.title + '\n' + container.category + '\n' + container.description + '\n' + ... Then create an TextIndex in your ZCatalog with the same name as the script. Use this index for your search and you won't have to worry about duplicate results. -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
participants (3)
-
Casey Duncan -
Mike Groves -
Oleg Broytmann