[Zope3-Users] Beyond ICatalog.searchResults

Frank Burkhardt fbo2 at gmx.net
Thu Apr 13 10:08:18 EDT 2006


Hi,

On Thu, Apr 13, 2006 at 04:27:15PM +0330, Mohsen Moeeni wrote:
> Hi;
> 
> Looking at ICatalog interface, I could not figure out
> how can I request some simple and common operations
> from my catalog.

You don't really have to cope with the catalog but with your indexes only.
The catalog's job is just to subscribe to object
creation/modification/remove events and to send your search request
to the index you want to use. Everything else depends on the indexes.


> - Sorting on a field index.

What do you mean by "sorting"? A index is a set of (word -> contentobject)
mappings. It doesn't make sense to sort it.


> - Returning the first N-th results (Hopefully without
>   awakening all catalog records - if that makes any sense)

Depends on the index only. i.e.: I modified Ting3 (a wrapper for
making TextIndexNG3 Zope3-ready) to accept not just unicode queries
but dictionaries, too. This way I'm able to do things like this:

 querydict={'query':"what i wanna %find",'similarity_ratio':0.2,'language':'en'}
 catalog.searchResults(ting3=querydict)

The Dictionary is passed to the 'ting3' index without any further checks.

You'll need to modify the index' apply-method to accept more than just
plain text queries and possibly more of the index to make it returning
just the first N-th results or other fancy stuff.


> - Defining an index which indexes an objects interfaces
>    i.e the output of interface.implemntedBy(ob)

Should be possible to use a slightly modified "text index" to do this.

Regards,

Frank


More information about the Zope3-users mailing list