[Zope3-dev] Sprintathon: searching?

Steve Alexander steve@cat-box.net
Tue, 05 Nov 2002 13:14:01 +0000


Janko Hauser wrote:

> On Mon, 2002-11-04 at 22:57, Steve Alexander wrote:
> 
>>> An open problem that's not really solved completely in the Zope2
>>> case (I believe) is how to extract the indexable text from an
>>> object once it is decided that it should be indexed.
>> 
>> In Zope3, I guess there will be an interface, ISearchableText, that
>>  defines a getSearchableText() method, and adapters from most
>> content types to that interface. (Change spelling according to
>> taste.)
>> 
> 
> Uh, just from the current usage of Z2 indexing, I think it is not
> enough to use a standard method to get the full text indexed content
> of a document type.

Getting an adapter to ISearchableText is not just using a standard 
method, such as calling PrincipiaSearchSource() in Zope 2.

Getting an adapter means that you can put into a separate component the 
logic of what attributes and method calls of an object make up its 
searchable text.

For example:

   class SearchableTextForContacts:
     __implements__ = ISearchableText
     __used_for__ = IContactInfo

     def __init__(self, contact):
         self.contact = contact

     def getSearchableText(self):
         c = self.contact
         return ' '.join(c.name(), c.address(), c.whatever())


> Think one wants to have to different indices, one
> for anonymous searches and another for managment, where different
> versions of a document or document content parts are indexed.

That's an interesting use-case. Can you expand on that, perhaps 
explaining a scenario where you've needed this separation?
If you want to email it to me, I'll put it up on a suitable wiki page 
once I've put one up for cataloguing use-cases.


> We also put keywords in such a full index, so we get all relevant documents
> with one search.

Good idea. You can do that using the adapter mechanism described above.


> I will add this, if the searching use cases are online, but wanted to
>  mention it here.

Thanks for giving your input.

--
Steve Alexander