Re: [Zope] Suppressing dupes in a concatenated ZCatalog query.

2005-07-28 Thread Jonathan


- Original Message - 
From: <[EMAIL PROTECTED]>

To: 
Sent: Thursday, July 28, 2005 4:57 PM
Subject: [Zope] Suppressing dupes in a concatenated ZCatalog query.



Hi All,

I have a ZCatalog with two text indexes, news_subj and news_text. Each
ZCatalog item also has a unique numeric ID.

I'd like to search news_subj and news_text simultaneously, with the
results checked for duplicates. In other words, if catalog item 1001 has
the word "foobar" in both the news_subj and news_text fields, I only
want it to show up once in my search results.

Here's what I've got, so far:


   


This correctly searches both fields, but, when "foobar" appears in both
news_subj and news_text, the result is displayed twice.

Can anyone give me a pointer on suppressing dupes in a concatenated
ZCatalog query? I'm sure there's an easy answer, but I haven't been able
to find it.


I had saved the following extract from a previous message on this mailing 
list, it may be of some help:



finally I got it working and maybe it helps someone else ..
you can't necessarily eliminate duplicates from the ZCatalog search results 
by sorting the mybrains because the same object
in the ZODB may be denoted my two different mybrains as far as I 
understand. so my "solution" was to make the absolute

URLs the keys of a dictionary and return the values(), i.e. the mybrains:
PythonMethod "uniq" (parameter "items" contains the results of a Catalog 
query):

d = {}
for item in items:
  url = item.getURL()
  d.update( { url: item } )
return d.values()

you can call it like that:

 



This is not a very elegant solution and will be cpu intensive, but if your 
catalog is not too large it may work for you.


hth

Jonathan 



___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] Suppressing dupes in a concatenated ZCatalog query.

2005-07-28 Thread Paul Winkler
On Thu, Jul 28, 2005 at 03:57:45PM -0500, [EMAIL PROTECTED] wrote:
> Hi All,
> 
> I have a ZCatalog with two text indexes, news_subj and news_text. Each
> ZCatalog item also has a unique numeric ID.
> 
> I'd like to search news_subj and news_text simultaneously, with the
> results checked for duplicates. In other words, if catalog item 1001 has
> the word "foobar" in both the news_subj and news_text fields, I only
> want it to show up once in my search results.
> 
> Here's what I've got, so far:
> 
> 
> 
> 
> 
> This correctly searches both fields, but, when "foobar" appears in both
> news_subj and news_text, the result is displayed twice.
> 
> Can anyone give me a pointer on suppressing dupes in a concatenated
> ZCatalog query? I'm sure there's an easy answer, but I haven't been able
> to find it.

I don't know if you can do that with ZCatalog alone.  Try Dieter's
AdvancedQuery product, it's been very helpful to me.
http://www.dieter.handshake.de/pyprojects/zope/#AdvancedQuery


-- 

Paul Winkler
http://www.slinkp.com
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] Suppressing dupes in a concatenated ZCatalog query.

2005-07-28 Thread abgillette
Hi All,

I have a ZCatalog with two text indexes, news_subj and news_text. Each
ZCatalog item also has a unique numeric ID.

I'd like to search news_subj and news_text simultaneously, with the
results checked for duplicates. In other words, if catalog item 1001 has
the word "foobar" in both the news_subj and news_text fields, I only
want it to show up once in my search results.

Here's what I've got, so far:





This correctly searches both fields, but, when "foobar" appears in both
news_subj and news_text, the result is displayed twice.

Can anyone give me a pointer on suppressing dupes in a concatenated
ZCatalog query? I'm sure there's an easy answer, but I haven't been able
to find it.

Thanks in advance,
Aaron
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )