[Zope] Re: How to avoid repeated records from an OR search in
ZCatalog? (Ausum)
joseph schlesinger
jschlesinger@slip.net
Mon, 26 Feb 2001 12:41:18 -0800
>As suggested by Caseman, it's possible in Zope 2.3 to do OR searches across
>different indexes using Zcatalog. Like this:
>
><dtml-in expr="catalog(title=query) + catalog(summary=query)+
>catalog(body=query) + catalog(notes=query)">
> ...........
></dtml-in>
>
>The problem is that if the queried word is found at more than one index, then
>its correspondant record will appear repeated as many times as the number of
>indexes for the same document
I came up with a work-around using Python Methods.
The first part probably isn't necessary with 2.3. It's only the dictionary
that's important.
resa=self.catalog(title=query)
resb=self.catalog(summary=query)
resc=self.catalog(body=query)
res=resa[:len(resa)] + resb[:len(resb)] + resc[:len(resc)]
d = {}
for item in res:
d.update( { item.data_record_id_ : item } )
return d.values()