[Zope-CMF] Re: TextIndex -> ZCTextIndex

Chris Withers chris at simplistix.co.uk
Fri Jul 23 05:56:43 EDT 2004


Casey Duncan wrote:
> from Products.ZCTextIndex.ZCTextIndex \
>     import PLexicon, ZCTextIndex, OkapiIndex
> 
> zcti = ZCTextIndex('SearchableText', 
>                    caller=self,
>                    index_factory=OkapiIndex,
>                    field_name=name, 
>                    lexicon_id='lexicon')
> self._catalog.addIndex(name, zcti)
> 
> And if you need to add a lexicon:
> 
> lexicon = PLexicon('lexicon', '', HTMLWordSplitter(), CaseNormalizer())
> self._setObject('lexicon', lexicon)
> 
> No big deal if you ask me.

Indeed. Where's this documented? It certainly isn't obvious from reading the 
ZCTextIndex source and I just ended up copying from Plone which does:

         class args:
             def __init__(self, **kw):
                 self.__dict__.update(kw)
         self.Catalog.manage_addProduct[ 'ZCTextIndex' ].manage_addLexicon(
             'Lexicon',
             elements=[
             args(group= 'Case Normalizer' , name= 'Case Normalizer' ),
             args(group= 'Stop Words' , name= " Don't remove stop words" ),
             args(group= 'Word Splitter' , name= "Whitespace splitter" ),
             ]
             )
         extra = args( doc_attr = 'SearchableText',
                       lexicon_id = 'Lexicon',
                       index_type  = 'Okapi BM25 Rank' )
         self.Catalog.manage_addIndex('SearchableText', 'ZCTextIndex', 
extra=extra)

cheers,

Chris

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk



More information about the Zope-CMF mailing list