[Zope3-Users] Searching and Indexing in Zope3

Frank Burkhardt fbo2 at gmx.net
Wed May 10 01:27:57 EDT 2006


Hi,

On Tue, May 09, 2006 at 10:32:45AM -0500, Sreeram Raghav wrote:
> Hi Frank,
> Thanks for the Zope3 Indexing and Searching HOWTO
> I translated your page to english and was trying to work it out.
> Here's exactly what i did:
> 
> 1. Logged into zope3 manager
> 2. went to "++etc++site/default/" and created an unnamed *initId* utility
> over there.
> 3. added a catalog named 'catalog1' with interface "*
> zope.app.catalog.interfaces.ICatalog*<http://192.168.60.225/++apidoc++/Interface/zope.app.catalog.interfaces.ICatalog/index.html>"
> and set access to "Public"
> 3. went inside catalog1 and added a TextIndex with an interface "
> zope.index.text.interfaces.ISearchableText" with Field Name as
> "searchableText".
> 4. then went into catalog1 and clicked on advanced and it was showing
> TextIndex with document count - 0 and word count - 0.
> It means that the objects are not being indexed, can you suggest what the
> problem could be.
> Than you

1. You have to check the "Callable" checkbox to tell the index that "searchableText" is
   a method and not just an attribute.

2. Selecting an interface means telling the index "Add (only!) objects of this type
   (=implementing this interface) to the index". This is not 100% correct - the index
   will add objects which can be adapted to the search interface, too.
   -> If you have objects that don't implement ISearchableText, you won't get them indexed
      without writing an adapter like this (untested!):
      
adapter.py:

 from zope.index.text.interfaces import ISearchableText
 from zope.component import adapts
 from zope.interface import implements
 
 MyObjectToSearchable(object)
    implements(ISearchableText)
    adapts(IMyObject)
    
    def __init__(self,context):
       self.context=context
    
    def searchableText(self):
       return self.context.data

configure.zcml:
   <adapter
      factory=".adapter.MyObjectToSearchable"
   />

Sorry, I'll add this adapter stuff to the howto asap :-) .

Regards,

Frank


More information about the Zope3-users mailing list