[Zope-dev] How to choose: Or, Not and And when using searchResults().

Chris McDonough chrism@digicool.com
Wed, 18 Apr 2001 08:53:52 -0400


BTW, it *is* possible to use AND, NOT, OR, and ANDNOT in the body of a
textindex query, e.g.

<dtml-in "Catalog(textindex="foo and bar or farfoo andnot flea")>
....

This is not a problem.

But the original question (and what is not possible currently), is how
to do something like:

<dtml-in "Catalog(textindex='foo' AND fieldindex='bar' OR
keywordindex=['flop'])">

...currently the best you can do is:

<dtml-in "Catalog(textindex='foo', fieldindex='bar',
keywordindex=['flop'])">
...

... which does an implicit intersection (AND) of all the results from
the indexes "textindex", "fieldindex" and "keywordindex".

To change this behavior, you need to do things like:

<dtml-let a="Catalog(textindex='foo')">
<dtml-let b="Catalog(fieldindex='bar')">
<dtml-let c="Catalog(keywordindex=['flop'])">

<dtml-let result="a + b + c">
<dtml-in result>
.....

the above example is a way to service a query like "textindex='foo' OR
fieldindex='bar' OR keywordindex=['flop']".

- C


Chris McDonough wrote:
> 
> Marco Nova wrote:
> > > DC has no no concrete plans to implement operators or precedence in
> > > catalog queries, although I think it's a really
> > > super-worthwhile idea.
> > > We're currently focusing on the things in the Zope 2.4 plan (see
> > > http://dev.zope.org/Resources/zope_240_plan.html).  If
> > > someone wanted to
> > > try to implement it, they could create a fishbowl project and I can
> > > provide assistance.
> >
> > Why don't integrate already working search engine such as pls (www.pls.com)
> > ?
> > It shouldn't be so much difficult to integrate.
> 
> It would not be possible to do field and keyword index queries against
> methods of Zope objects with a third-party indexer.  It would
> additionally not be possible to full-text-index anything but the results
> of a rendered HTML page.
> 
> If ZCatalog did nothing but create full text indexes of rendered HTML, I
> think we'd be all for going with a third-party search engine instead of
> continuing to maintain it. But ZCatalog is not just about searching
> text.  ZCatalog currently lets you relate objects in a Zope instance to
> each other in ways that aren't possible without it.  For example, you
> can catalog a bunch of different kinds of objects, and perform a catalog
> query to retrieve only DTML Document objects.  Likewise, you can create
> and index and subsequently perform a query that lets you get at objects
> which have an attribute "foo" that starts with the letter "g".  This
> kind of granularity is not possible with nonintegrated indexers.
> 
> Of course that doesn't mean you can't use htdig or pls to index a Zope
> site if that's what you'd like to do...