Refresh metadata without index in Plone ZCatalog

Zope directories contain directory objects with index attributes (for use as query arguments) and metadata attributes (available when accessing the search result). Index attributes can be reindexed in cases where the logic for calculating the index has changed.

I noticed that the metadata field getThumbnailPath

was incorrect for one of my Archetypes based content types. Of course, the content of the metadata field does not automatically change when the method changes; thus, I would like to fix it in the upgrade phase.

However, there does not appear to be a documented way to do this for metadata fields; the documentation reindexing directory does not say this.

What would be the most modern way to do this?

  • Is there a way to update a specific metadata field?
  • Do I need to do a directory search for the affected type and re-index every single item (recalculate every other index and metadata field)?
  • Should I create an index with the same name and should I delete this index afterwards, or does it not matter?

Refresh . For now I have chosen the second option, but it took ~ 100 seconds for 1069 objects of this type and this could easily take a watch with all other objects affected; it would be nice to have a more selective way.

+3


source to share


1 answer


The catalog metadata is updated every time the object is indexed. I think the fastest way to update it is to re-index each object by specifying one index to update:

portal_catalog.catalog_object(obj, idxs=['getId'])

      



The time required will depend on how many objects and how many fields are included in the metadata.

(In other cases, when you want to index without spending time updating the catalog metadata, go with this same method update_metadata = False.)

+5


source







All Articles