joseph schlesinger wrote:
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()
That actually looks like a good solution. Yes, you can omit the slicing in 2.3, so line 4 becomes: res=resa+resb+resc The unfortunate result of this though is that all results are loaded into memory, so the results aren't lazy anymore. I don't know of a way around that given the current ZCatalog implementation, however. 8^( -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>