[ZODB-Dev] (Un)Index questions

Andrew Dalke Andrew Dalke" <dalke@dalkescientific.com
Fri, 12 Oct 2001 03:05:54 -0600


Steve Alexander:
>Don't use the SearchIndex package. It is only there to be 
>backwards-compatible.
>
>Instead, use Products/PluginIndexes.

Aaaahh, okay.  Thanks for the pointer.

Bit of history.  This project used Catalog and ZODB from
Zope 2.2.2.  (Note: not Zope proper and not ZCatalog.)  UnIndex
only indexed a single property of an object and we needed to
index a list of properties, so I hacked a new version of
UnIndex.py to support it.  (Actually, some fields are indexed
with a list of properties, others with a single value, so I
modified the code so I passed in an extractor adapter function,
rather than passing in the attribute name.)

I also didn't like the way UnIndex range searches were specified
(via the '_range' suffix to the name of field to search) so
I added a new Range class, so I could do

   num_atoms = Range(10, 50), avg_mw = Range(max = 1000.0)

This called for hacking a new _apply_index method.

We're migrating to 2.4.1, so I've been trying to figure out
what needed to be rehacked.  Hence I searched for UnIndex and
looked at it and its neighbors.

So how should I have learned about this change?  One
possibility is to put a note in a SearchIndex/README.txt file,
just like there's a PluginIndexes/README.txt.  Another would
be to generate a DeprecationWarning.

Just did a google search for "PluginIndexes SearchIndex."  All
of eight hits (the other 200 hits were judged too similar).
Following one of the links led me to:
  http://www.zope.org/Members/ajung/howto/PluginIndexes/

Some questions.  Can "Products" be used outside of Zope?  I
don't use ZCatalog.  What's a SimpleItem (other than "Zope
Masala")?  It seems Zope specific, so do I need to derive
from it?  What happens if I don't.

But these are just worries.  It doesn't look too hard to
convert my modified SearchIndex/KeywordList.py into a
PluginIndexes, so if this testing works I'll try porting
to the new framework tomorrow.


Me:
>> So one case uses 'weightedUnion' and the other uses 'union'.
>> Could someone tell me why there's a difference?  My intuition
>> tells me there shouldn't be one.

Steve Alexander:
>The documentation for these is in BTrees/Interfaces.py

The documentation points out that, in this context, those two
functions return the same result.  So I'm pointing out that
the code is messier and more confusing than it needs to be.
But it's deprecated, so no need to change.

                    Andrew
                    dalke@dalkescientific.com