Zcatalog & KeywordIndex
I'm having some difficulties using my Zcatalog & my KeywordIndex within that catalog. I have a subdirectory of different files, each with a property called "repo_keywords". I created a KeywordIndex called "repo_keywords". When I search using this, I must enter the exact text within the repo_keywords property (instead of just one word or a phrase). Also, when I add a new file, I have to re-find everything in my Zcatalog, update catalog doesn't seem to work? (Win32, Zope 2.6.1, Python 2.1.3) Thanks, John Toews
--On Dienstag, 20. Mai 2003 14:10 Uhr -0500 John Toews <john@academiccolab.org> wrote:
I'm having some difficulties using my Zcatalog & my KeywordIndex within that catalog.
I have a subdirectory of different files, each with a property called "repo_keywords". I created a KeywordIndex called "repo_keywords". When I search using this, I must enter the exact text within the repo_keywords property (instead of just one word or a phrase).
A keyword is as the name says a keyword. Means: you can only search for existing keywords and you *can not* use partial words. That's what fulltext indexes are for. Check the Zope Book for details! -aj
John Toews wrote at 2003-5-20 14:10 -0500:
I'm having some difficulties using my Zcatalog & my KeywordIndex within that catalog.
I have a subdirectory of different files, each with a property called "repo_keywords". I created a KeywordIndex called "repo_keywords". When I search using this, I must enter the exact text within the repo_keywords property (instead of just one word or a phrase).
As Andreas already wrote, phrases or substrings are not supported by "KeywordIndex". A "KeywordIndex" interprets the value as a sequence and indexes the object under each element in the sequence. If the document's value for the index is, e.g., "('red', 'green', 'blue')", then the document is indexed under "red", "green" and "blue" and can be found under any of these terms. In <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> you find an alternative (to the Zope Book) description of ZCatalog and its indexes. Not sure, whether you will find it more useful.
Also, when I add a new file, I have to re-find everything in my Zcatalog, update catalog doesn't seem to work? (Win32, Zope 2.6.1, Python 2.1.3)
The is explained in the above reference: The integration between Zope and ZCatalog is really loose (almost non existant!). You might look for CMF to get tighter integration. "ZCatalog" provides a method "catalog_object" which can be used to catalog single objects (e.g. after you added a new object or made some modifications). When you build your own objects (either through a ZClass or in a Python based product), you can inherit from "CatalogPathAware" ("CatalogAware" for "ZClass"). This handles automatic cataloguing/uncataloguing when such objects are created/deleted (provided the catalog is named "Catalog"). Even then, you must explicitely request recataloguing after modifications. "updateCatalog" recatalogs all objects, ZCatalog already has catalogued. This means, it does not work for new objects... As "updateCatalog" is very expensive (one many objects are catalogued), you definitely do not want to use it after any modification ;-) Dieter
participants (3)
-
Andreas Jung -
Dieter Maurer -
John Toews