[Zope-dev] ZCatalog/TextIndex/OR - keyword search

Arno Gross arno.gross@consotec.de
Thu, 8 Feb 2001 11:53:28 -0100


Hi Steve,
maybe I'm missing one step. If I create a TextIndex for search_text (or
PrincipiaSearchSource)
I have to tell somewhere how this index is composite? Becaus I try to
list PrincipiaSearchSource in my result list it's empty.
Thanks
   Arno Gross, email: arno.gross@consotec.de
On Thu, 08 Feb 2001, Steve Alexander wrote:
> Arno Gross wrote:
> 
> > I understand that the search terms for a field with TextIndex are ORed
> > and the fields in a search form are ANDed.
> > But assume the following:
> >  * I have three fields (eg. abstract, content, title) with TextIndex
> >  * I have one field (eg. category) with FieldIndex
> > 
> > When searching I want just give a keyword for the three TextIndex fields
> > and a search term for category.
> > The applying expression should look like this:
> > 
> > (abstract=keyword OR content=keyword OR title=keyword) AND
> > category=searchTerm
> > 
> > Any hints?
> 
> Create a method or computed attribute called "search_text" that returns the
> concatenation of abstract, content and title.
> 
> In ZPatterns I'd use the following SkinScript:
> 
>   WITH SELF COMPUTE
>     search_text='%s %s %s' % (abstract, content, title)
> 
> An equivalent PythonScript as a method of your ZClass would be:
> 
> name: search_text
>   return '%s %s %s' % (container.abstract, container.content, container.title)
> 
> Use a similar method in a python class, replacing "container" with "self".
> 
> Set up search_text as a TextIndex in your ZCatalog.
> 
> Then, query the catalog with something like:
> 
>   Catalog(search_text=keyword_for_query, category=searchTerm)
> 
> The standard name for the search_text method or attribute is
> PrincipiaSearchSource. That's why PrincipiaSearchSource is a default
> TextIndex in a new ZCatalog.
> 
> --
> Steve Alexander
> Software Engineer
> Cat-Box limited
> http://www.cat-box.net
> 
> 
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )