Arno Gross wrote:
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.
You need to provide a method or property or attribute that gives the catalog the concatenated search text. You haven't said what kind of objects you are cataloging: are they ZClass instances, Python class instances, DTML Documents... ? You may be able to use a PythonScript in the acquisition path of your objects to do this work.
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