[Bug] Keyword index 'and' operator (was: [Zope] (no subject))

Dieter Maurer dieter@handshake.de
Tue, 22 Apr 2003 20:54:22 +0200


Terry Kerr wrote at 2003-4-21 09:04 +1000:
 > I don't think its a bug...it looks very purposefull!  The KeywordIndex
 > uses the same _apply_index() as the FieldIndex, so will match on the same
 > values.  The method uses BTree.IITreeSet.intersection if the operator is
 > 'and' on the keywords, and as clearly documented in IITreeSet.Interfaces,
 > the intersection method if provided two sets, one which is None, will
 > return the other set.  So if one keyword has no matches, then the result
 > is essentially ignored.

That's an implementation argument.
However, semantics is more essential than implementation
or, more precisely, the implementation must be such that its
implements the semantics.

When your query is

     keywordindex= {'query' : [key1,key2], operator='and',}

then the semantics (of the "and" operator)
dictates that you get (the) objects indexed
under both "key1" and "key2".
Thus, when (e.g.) no object is indexed under "key1" you must get the empty
set.

 > ....
 > > Terry Kerr wrote at 2003-4-20 15:54 +1000:
 > > > I have a Keyword Index setup in a Catalog, and when I search for more
 > > > than one keyword using a query such as {'query':['one', 'two'],
 > > > 'operator':'and'}, and there are no indexed records with either of
 > > > the keywords, all records in the Catalog are returned.  In this
 > > > instance, I want NO records to be returned.  Is this easily possible?
 > >
 > > Sounds like a bug...
 > >
 > > File a collector report (<http://collector.zope.org>).
 > >
 > > Look at the implementation and try to fix the bug.


Dieter