[Zope-Coders] Proposal for minor ZCatalog improvement

Shane Hathaway shane@zope.com
Mon, 11 Nov 2002 09:56:24 -0500


Andreas Jung wrote:
> All ZCatalog indexes are using the id of the indexes to index attributes
> with the same name. ZCTextIndex introduced a new approach by seperating
> the id of the index from the attribute name to be indexed. This is a nice
> idea and allows to have different indexes on the same attribute name
> (e.g. having a FieldIndex and a text index on a string attribute).
> 
> I propose add this functionality to all Zope indexes. All interface for
> pluggable indexes should get a new method getIndexedAttribute() that
> returns the name of the attribute that will be indexed by this index.
> The indexes tab of the ZCatalog should be modified to display the
> indexes as:
> 
> topic_txt  (TextIndex on topic) ...
> topic_field (FieldIndex on topic)
> 
> For backwards compatiblity getIndexedAttribute() would  return the
> id of the index if the indexes has no dedicated attribute to keep
> the name of the indexed attribute.

This is a good thing to point out, but what about the possibility of 
allowing ZCTextIndexes to index multiple attributes?  Currently we have 
"SearchableText()" methods all over that return "self.description + ' ' 
+ self.title + ' ' + self.body".  We could instead let the ZCTextIndex 
perform that work, making it more configurable.

This would make getIndexedAttribute() impossible to implement correctly. 
  Maybe getIndexedAttributeNames()?  The ZMI could choose how to format 
multiple attributes.

Shane