[ZCM] [ZC] 195/ 2 Accept "Catalog.searchResults - OR search bug"

Collector: Zope Bugs and Patches ... zope-coders@zope.org
Tue, 05 Feb 2002 13:35:37 -0500


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 '+'

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 
________________________________________
= Request - Entry #1 by Anonymous User on Feb 5, 2002 1:07 pm

I have encountered a problem with OR searches in zcatalog.

 If the first search set is empty then the final search
 set is also empty, even if the second search set has
 valid results.

 Example:

 <dtml-in "Catalog.searchResults({'fieldindexA' : 'goodvalue'}, {'fieldindexA' : 'goodvalue'})">
              /* returns a valid result set*/

 <dtml-in "Catalog.searchResults({'fieldindexA' : 'badvalue'}, {'fieldindexA' : 'badvalue'})">
             /* returns a valid result set (empty set)*/

 <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)*/

 where:
    goodvalue - exists in fieldindex
    badvalue - does not exist in fieldindex


 The ultimate search logic I want to use is:

 ('owner_id' = 'owner') AND ('class1' = 'userdata' OR 'class2' = 'userdata')

 Where:
  owner_id, class1, class2 are zcatalog indexes
  owner, userdata are user-supplied (via html form) data

 When I try:

 <dtml-in Catalog.searchResults({'owner_id' : 'owner', 'class1': 'userdata'}, {'owner_id' : 'owner', 'class2' : 'userdata'})">

 I get an empty result set if 'class1' does not contain 'userdata', even
 if 'class2' does contain 'userdata' ('owner_id' matches 'owner' in both cases)

 Is this a bug, or am I doing something wrong?
 (I tried posting a message on the zope bulletin board on
 Yahoo, but didn't get a response).

 Thanks,

 Jonathan Hobbs

==============================================================