[Zope-Coders] Re: [ZC] 195/ 2 Accept "Catalog.searchResults - OR search bug"
Jonathan Hobbs
hobbs@magma.ca
Tue, 5 Feb 2002 14:10:39 -0500
Thanks for the quick response!
----- Original Message -----
From: "Collector: Zope Bugs and Patches ..." <zope-coders@zope.org>
To: "Jonathan Hobbs" <hobbs@magma.ca>; "ajung" <andreas@zope.com>; "klm"
<klm@zope.com>; "Brian" <brian@zope.com>; "chrism" <chrism@zope.com>;
"_Accepted_ recipient" <zope-collector-monitor@zope.org>
Sent: February 5, 2002 1:35 PM
Subject: [ZC] 195/ 2 Accept "Catalog.searchResults - OR search bug"
> Issue #195 Update (Accept) "Catalog.searchResults - OR search bug"
> Status Accepted, Zope/bug medium
> To followup, visit:
> http://collector.zope.org/Zope/195
>
> ==============================================================
> = Accept - Entry #2 by ajung on Feb 5, 2002 1:35 pm
>
> Status: Pending => Accepted
>
> Supporters added: ajung
>
> I can reject and accept this issue :-)
>
> reject: your queries perform an AND search. The API
> documentation of the ZCatalog show how to perform OR
> searches by combining two queries using '+'
>
I previously tried and encountered a different problem with the '+'
operator:
<dtml-in Catalog({'owner_id' : 'owner', 'class1': 'userdata'}) +
atalog( {'owner_id' : 'owner', 'class2' : 'userdata'})">
Works fine, as long as the user doesn't enter a null value for 'userdata'
(ie. user trying to get
all records for 'owner_id' regardless of class1 or class2 values). If
'userdata' is null then the result set returned contains two copies of all
records that match owner_id - is this supposed to happen?
I haven't been able to figure out how to get the result set to eliminate
duplicates (I can programatically ignore the duplicates, but the batched
displays get messed up as the loop variables are set by the <dtml-in> tag).
Any ideas?
> accept:
> <dtml-in "Catalog.searchResults({'fieldindexA' : 'goodvalue'},
{'fieldindexA' : 'badvalue'})">
> /* returns a valid result set*/
>
> <dtml-in "Catalog.searchResults({'fieldindex' : 'badvalue'},
{'fieldindex' : 'goodvalue'})">
> /* returns INVALID result set (empty set)*/
> should return in both cases an empty result set for this
> AND search. I can reproduce this problem there is not fix
> available yet.
>
> - aj
My understanding, from the documentation, is that ({fielda : valuea,
fieldb:valueb}) should be an AND search and that ({fielda : valuea},
{fieldb:valueb}) should be an OR search (which is the way Zope 2.4.2 works
at present). In which case both of the above Catalog.searchResults(...)
examples should return non-empty sets, NOT empty sets.
The concept of any index/value pairs within braces { } being treated as
'AND', and having an implicit 'OR' between two sets of braces { }, { }
gives a good deal of flexibility and is a easy/intuitive to use!
Thanks again,
Jonathan Hobbs