Hi, I'm messing around with a Plugable Index that can take an NOT operator. (regular field/keyword indexes can just do AND or OR (and of course range). I intend to release my code on zope.org, but first I though I'd write some unit tests. EasyKeywordIndex (as it's currently called) extends keywordIndex and adds three operators 'not', 'notor', 'notand'. ('not' == 'notor') It works by first doing range (i.a.), then doing AND/OR and finally (an the only new stuff) diff it agains all indexed documents. To be able to make the diff at the end I have added a index attribute self._all that is a IISet of all indexed documentIds. Now to the question(s): (I allready answered one of the writting this e-mail ;-) If a document doesn't have the attribute it's index it still is included in the index (as an unindex entry). Why does it work this way, I would have thought that if a document doesn't have the indexing attribute it should be not be included in the index? This would free up allot of references to documents that will never be search through the index, at least in an application where the ZCatalog has allot of indexes that index allot of classes with quite different types of meta-data. For the NOT-aware index it would mean a great different. Instead of returning all documentIds that ever been through the ZCatalog that doesn't match, it would return a much smaller result list. Of course the not index will most probably be combined with other query operators (such as a field of meta_data in my case) but returning a smaller result list would make not indexes more effective, right? I love to get this accepted as a patch for the unindex, I might also have a look at TextIndex and PathIndex, while I'm at it :-) ( TextIndexes does partially do NOT with the 'andnot', 'ornot' opertators, but they require that the first search argument is not not (e.g. "first AND NOT second", not "NOT first AND second") ) Best Regards, Johan Carlsson -- Torped Strategi och Kommunikation AB Johan Carlsson johanc@torped.se Mail: Birkagatan 9 SE-113 36 Stockholm Sweden Visit: Västmannagatan 67, Stockholm, Sweden Phone +46-(0)8-32 31 23 Fax +46-(0)8-32 31 83 Mobil +46-(0)70-558 25 24 http://www.torped.se http://www.easypublisher.com
At 11:04 2002-07-06 +0200, Johan Carlsson [Torped] said:
I intend to release my code on zope.org, but first I though I'd write some unit tests.
Ok, writing the UnitTest took more time that writing the Index :-) Here it is any way: http://www.zope.org/Members/johanc/EasyIndexes Usage: Not 'a' in foo: record = { 'foo' : { 'query' : ['a'] , 'operator' : 'not' } } Not ( 'b' or 'e' ) in foo: record = { 'foo' : { 'query' : ['b','e'] , 'operator' : 'notor' } } Not ( 'b' and 'e' ) in foo: record = { 'foo' : { 'query' : ['b','e'] , 'operator' : 'notand' } } -- Torped Strategi och Kommunikation AB Johan Carlsson johanc@torped.se Mail: Birkagatan 9 SE-113 36 Stockholm Sweden Visit: Västmannagatan 67, Stockholm, Sweden Phone +46-(0)8-32 31 23 Fax +46-(0)8-32 31 83 Mobil +46-(0)70-558 25 24 http://www.torped.se http://www.easypublisher.com
participants (1)
-
Johan Carlsson [Torped]